Closed mbezhanov closed 5 days ago
I think it would be better to have a different field in the struct to contain the expression.
This way, someone could generate code to use the expression in a query.
I've updated the PR accordingly.
How do you feel about this format for the Index
structures:
That corresponds to the following DDL:
CREATE TABLE test_index_expressions (
col1 int,
col2 int,
col3 int
);
CREATE INDEX idx11 ON test_index_expressions (col1, (col2 + col3), (POW(col3, 2)))
This looks good 🎉
Perhaps it makes sense to have a flat struct for Index
type Index struct {
Name string
Columns []string
Expressions []string
}
Perhaps it makes sense to have a flat struct for
Index
:white_check_mark: Done
This provides a fix to #244.
DDL for testing:
Before the patch, generation failed with the following error:
MySQL:
SQLite:
After the patch, generation completes successfully with the following information being collected:
Please note that PostgreSQL was not affected by this issue, as it uses the expression as a
column_name
rather than omitting it:@stephenafamo would you prefer to use the expression contents as a
column_name
for SQLite and MySQL as well, rather than omitting them? I checked two different database GUIs. The first one used the expression contents as acolumn_name
, and the others one omitted the expression from the column listing.