Repository navigation
Add support for DEFAULT (expression) in column definitions - #306
Conversation
|
@wojtekn Thank you for looking into this! Good job working with the AST and even fixing the old driver 👍 Generally, it looks good to me, and it is the right approach to work with the new driver. On the AST side, I spotted one issue that is related to only implementing a subset of the expression functionality, and that is that for expressions such as this one: DEFAULT (DATE_ADD(NOW(), INTERVAL 1 YEAR))It would detect and incorrectly return the value of Additionally, in the MySQL column metadata, there needs to be an indication that it has a |
DEFAULT (expression) in column definitions
|
@wojtekn It turns out I can push to this branch. I just have no idea how to manage PRs from forks 😆 I added one commit with a quick implementation of the full TODO:
Thanks again for pushing this forward! |
|
No more feedback here, so let's get it in. |
|
@JanJakes, thanks for taking it over and finishing it. |
Summary
Adds full support for
DEFAULT (expression)inCREATE TABLEstatement column definitions.Fixes #300 - Support for
DEFAULT (now()).Problem
The MySQL 8.0 syntax
DEFAULT (function())was failing because the translator only consumed a single token after the DEFAULT keyword. For expressions likeDEFAULT (now()), it would only capture the opening parenthesis(, causing the query translation to fail.Solution
Full
DEFAULT (expression)support in the AST driver.Enhanced the
DEFAULTclause handler inWP_SQLite_Translatorto: