@@ -1162,24 +1162,42 @@ RenameColumnClause:
1162
1162
ConstraintClauses:
1163
1163
_add OutOfLineConstraint // Note: in docs is _add OutOfLineConstraints, but actual is _add OutOfLineConstraint.
1164
1164
{
1165
- $$ = []ast.AlterTableClause{&ast.AddConstraintClause{}}
1165
+ $$ = []ast.AlterTableClause{&ast.AddConstraintClause{
1166
+ Constraints: []*ast.OutOfLineConstraint{$2 .(*ast.OutOfLineConstraint)},
1167
+ }}
1166
1168
}
1167
1169
// | _add OutOfLineRefConstraint
1168
1170
| _modify _constraint Identifier ConstraintState CascadeOrEmpty
1169
1171
{
1170
- $$ = []ast.AlterTableClause{&ast.ModifyConstraintClause{}}
1172
+ constraint := &ast.OutOfLineConstraint{}
1173
+ constraint.Name = $3 .(*element.Identifier)
1174
+ $$ = []ast.AlterTableClause{&ast.ModifyConstraintClause{
1175
+ Constraint: constraint,
1176
+ }}
1171
1177
}
1172
1178
| _modify _primary _key ConstraintState CascadeOrEmpty
1173
1179
{
1174
- $$ = []ast.AlterTableClause{&ast.ModifyConstraintClause{}}
1180
+ constraint := &ast.OutOfLineConstraint{}
1181
+ constraint.Type = ast.ConstraintTypePK
1182
+ $$ = []ast.AlterTableClause{&ast.ModifyConstraintClause{
1183
+ Constraint: constraint,
1184
+ }}
1175
1185
}
1176
1186
| _modify _unique ' (' ColumnNameList ' )' ConstraintState CascadeOrEmpty
1177
1187
{
1178
- $$ = []ast.AlterTableClause{&ast.ModifyConstraintClause{}}
1188
+ constraint := &ast.OutOfLineConstraint{}
1189
+ constraint.Type = ast.ConstraintTypeUnique
1190
+ constraint.Columns = $4 .([]*element.Identifier)
1191
+ $$ = []ast.AlterTableClause{&ast.ModifyConstraintClause{
1192
+ Constraint: constraint,
1193
+ }}
1179
1194
}
1180
1195
| _rename _constraint Identifier _to Identifier
1181
1196
{
1182
- $$ = []ast.AlterTableClause{&ast.RenameConstraintClause{}}
1197
+ $$ = []ast.AlterTableClause{&ast.RenameConstraintClause{
1198
+ OldName: $3 .(*element.Identifier),
1199
+ NewName: $5 .(*element.Identifier),
1200
+ }}
1183
1201
}
1184
1202
| DropConstraintClauses
1185
1203
{
@@ -1203,15 +1221,28 @@ DropConstraintClauses:
1203
1221
DropConstraintClause:
1204
1222
_drop _primary _key CascadeOrEmpty DropConstraintProps
1205
1223
{
1206
- $$ = &ast.DropConstraintClause{}
1224
+ constraint := &ast.OutOfLineConstraint{}
1225
+ constraint.Type = ast.ConstraintTypePK
1226
+ $$ = &ast.DropConstraintClause{
1227
+ Constraint: constraint,
1228
+ }
1207
1229
}
1208
1230
| _drop _unique ' (' ColumnNameList ' )' CascadeOrEmpty DropConstraintProps
1209
1231
{
1210
- $$ = &ast.DropConstraintClause{}
1232
+ constraint := &ast.OutOfLineConstraint{}
1233
+ constraint.Type = ast.ConstraintTypeUnique
1234
+ constraint.Columns = $4 .([]*element.Identifier)
1235
+ $$ = &ast.DropConstraintClause{
1236
+ Constraint: constraint,
1237
+ }
1211
1238
}
1212
1239
| _drop _constraint Identifier CascadeOrEmpty DropConstraintProps
1213
1240
{
1214
- $$ = &ast.DropConstraintClause{}
1241
+ constraint := &ast.OutOfLineConstraint{}
1242
+ constraint.Name = $3 .(*element.Identifier)
1243
+ $$ = &ast.DropConstraintClause{
1244
+ Constraint: constraint,
1245
+ }
1215
1246
}
1216
1247
1217
1248
CascadeOrEmpty:
0 commit comments