Insert of multiple values that contain an unknown column don't trigger an exception

Issue #3666 resolved
Athena Yao created an issue

Inserting just one value triggers the CompileError 'Unconsumed column names' just fine.

Will provide patch shortly.

Test case attached. Before fix:

$ python2 unknown_columns.py
Expected fail (single value): CompileError('Unconsumed column names: unknown_column',)
Traceback (most recent call last):
  File "unknown_columns.py", line 30, in <module>
    raise RuntimeError("(multiple values): shouldn't hit here")
RuntimeError: (multiple values): shouldn't hit here

After fix:

$ python2 unknown_columns.py
Expected fail (single value): CompileError('Unconsumed column names: unknown_column',)
Expected fail (multiple values): CompileError('Unconsumed column names: unknown_column',)

Comments (11)

  1. Mike Bayer repo owner

    this is by design, last i looked at this the complexity of checking every dictionary would render far too much time spent on a case that's supposed to be optimized. im a little surprised i dont see this documented though, I'm pretty sure there's a note about it somewhere but we can add more.

  2. Athena Yao reporter

    I agree that it's probably not worth the effort to check all elements that are being inserted.

    Everywhere else in this function, though, there's an attempt made to use the first element of the values list to stand for all potential statement parameters; that it's not the case in this one spot feels like an oversight.

  3. Mike Bayer repo owner

    yah sorry I was incorrect, the "check only the first entry" is for conn.execute(stmt, values). With this one, you have the bad entry in the first element as well so that should definitely raise! the fix seems to repair a definite oversight.

  4. Mike Bayer repo owner
    • move out unconsumed names tests from test_compiler out to test_insert, test_update
    • establish consistent names between existing unconsumed names tests and new ones added per ref #3666

    → <<cset 6b7c207801d8>>

  5. Athena Yao reporter

    Awesome, thank you! I'm ashamed to admit this has bitten me too many times (in unit tests especially), so this will make my life better.

  6. Log in to comment