allow column default functions access to the ExecutionContext

Issue #559 resolved
Mike Bayer repo owner created an issue

we get a lot of requests for column defaults to look at other parameters being sent.

  1. add a step in schema.ColumnDefault to inspect the incoming default argument to see if a. its a callable, and b. takes no arguments. if so, wrap it in another function that will take ExecutionContext as its argument (or should it take just statement + parameters? all args ? probably the context is the most generic).

  2. change the constructor of DefaultRunner to take ExecutionContext instead of connection/dialect.

  3. change the defaultrunner() function on all dialects to take ExecutionContext as an argument, instead of Connection.

  4. change base.connection.execute_default() to produce a new ExecutionContext in a manner similar to execute_text() right below it, and send it to its call to defaultrunner().

  5. change engine.default.DefaultExecutionContext._process_defaults() to call defaultrunner() with its self as the execution context argument.

  6. add a unit test to test/sql/defaults.py, testing a python default function that looks for a context argument, and then pulls some information about the bind parameters when it executes.

Comments (3)

  1. Log in to comment