-
Notifications
You must be signed in to change notification settings - Fork 51
Handle columns who use functions as defaults #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1074,6 +1074,13 @@ func (t *tableSQLVertexGenerator) GetAddAlterDependencies(table, _ schema.Table) | |
| mustRun(t.GetSQLVertexId(table, diffTypeAddAlter)).after(buildTableVertexId(*table.ParentTable, diffTypeAddAlter)), | ||
| ) | ||
| } | ||
|
|
||
| for _, col := range table.Columns { | ||
| for _, depFunction := range col.DependsOnFunctions { | ||
| deps = append(deps, mustRun(t.GetSQLVertexId(table, diffTypeDelete)).after(buildFunctionVertexId(depFunction, diffTypeDelete))) | ||
| } | ||
| } | ||
|
|
||
| return deps, nil | ||
| } | ||
|
|
||
|
|
@@ -1142,6 +1149,13 @@ func (t *tableSQLVertexGenerator) GetDeleteDependencies(table schema.Table) ([]d | |
| mustRun(t.GetSQLVertexId(table, diffTypeDelete)).after(buildTableVertexId(*table.ParentTable, diffTypeDelete)), | ||
| ) | ||
| } | ||
|
|
||
| for _, col := range table.Columns { | ||
| for _, depFunction := range col.DependsOnFunctions { | ||
| deps = append(deps, mustRun(t.GetSQLVertexId(table, diffTypeDelete)).before(buildFunctionVertexId(depFunction, diffTypeDelete))) | ||
| } | ||
| } | ||
|
|
||
| return deps, nil | ||
| } | ||
|
|
||
|
|
@@ -1407,13 +1421,26 @@ func buildColumnVertexId(columnName string, diffType diffType) sqlVertexId { | |
| } | ||
|
|
||
| func (csg *columnSQLVertexGenerator) GetAddAlterDependencies(col, _ schema.Column) ([]dependency, error) { | ||
| return []dependency{ | ||
|
|
||
| var deps []dependency = []dependency{ | ||
| mustRun(csg.GetSQLVertexId(col, diffTypeDelete)).before(csg.GetSQLVertexId(col, diffTypeAddAlter)), | ||
| }, nil | ||
| } | ||
|
|
||
| for _, depFunction := range col.DependsOnFunctions { | ||
| deps = append(deps, mustRun(csg.GetSQLVertexId(col, diffTypeDelete)).after(buildFunctionVertexId(depFunction, diffTypeDelete))) | ||
| } | ||
|
|
||
| return deps, nil | ||
|
|
||
| } | ||
|
|
||
| func (csg *columnSQLVertexGenerator) GetDeleteDependencies(_ schema.Column) ([]dependency, error) { | ||
| return nil, nil | ||
| func (csg *columnSQLVertexGenerator) GetDeleteDependencies(col schema.Column) ([]dependency, error) { | ||
|
|
||
| var deps []dependency | ||
| for _, depFunction := range col.DependsOnFunctions { | ||
| deps = append(deps, mustRun(csg.GetSQLVertexId(col, diffTypeDelete)).before(buildFunctionVertexId(depFunction, diffTypeDelete))) | ||
| } | ||
| return deps, nil | ||
|
Comment on lines
+1424
to
+1443
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this does nothing right now, because the functions exist in the root graph. Ideally, we merge the graphs, but that's too much effort right now.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So they should be removed ? |
||
| } | ||
|
|
||
| type renameConflictingIndexSQLVertexGenerator struct { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the currently awkward part about column sql generation: add/delete of columns is pushed under table add/alter.
As a result, what I believe you need to do:
^
The same is true if the table is being totally created or totally deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that what I'm doing no ?
Here we're in table add/alter, and we add a dep for each column's function that have a dependency, and just bellow the delete (in opposite mode)
diffTypeDeletemay be wrong there however ^^'