@@ -10157,6 +10157,72 @@ where
10157
10157
},
10158
10158
},
10159
10159
},
10160
+ {
10161
+ Name : "decimals with foreign keys" ,
10162
+ Dialect : "mysql" ,
10163
+ SetUpScript : []string {
10164
+ "create table parent (d decimal(4, 2) primary key);" ,
10165
+ "insert into parent values (1.23), (45.67), (78.9);" ,
10166
+ },
10167
+ Assertions : []ScriptTestAssertion {
10168
+ {
10169
+ Query : "create table child_dec_4_2 (d decimal(4,2), foreign key (d) references parent (d));" ,
10170
+ Expected : []sql.Row {
10171
+ {types .NewOkResult (0 )},
10172
+ },
10173
+ },
10174
+ {
10175
+ Query : "insert into child_dec_4_2 values (1.23), (45.67), (NULL);" ,
10176
+ Expected : []sql.Row {
10177
+ {types .NewOkResult (3 )},
10178
+ },
10179
+ },
10180
+ {
10181
+ Query : "insert into child_dec_4_2 values (1.229999), (45.6711111), (78.90);" ,
10182
+ Expected : []sql.Row {
10183
+ {types .NewOkResult (3 )},
10184
+ },
10185
+ },
10186
+
10187
+ {
10188
+ Skip : true ,
10189
+ Query : "create table child_dec_4_1 (d decimal(4,1), foreign key (d) references parent (d));" ,
10190
+ Expected : []sql.Row {
10191
+ {types .NewOkResult (0 )},
10192
+ },
10193
+ },
10194
+ {
10195
+ Skip : true ,
10196
+ Query : "insert into child_dec_4_1 values (78.9);" ,
10197
+ ExpectedErr : sql .ErrForeignKeyParentViolation ,
10198
+ },
10199
+
10200
+ {
10201
+ Skip : true ,
10202
+ Query : "create table child_dec_3_2 (d decimal(3,2), foreign key (d) references parent (d));" ,
10203
+ Expected : []sql.Row {
10204
+ {types .NewOkResult (0 )},
10205
+ },
10206
+ },
10207
+ {
10208
+ Skip : true ,
10209
+ Query : "insert into child_dec_3_2 values (1.23);" ,
10210
+ ExpectedErr : sql .ErrForeignKeyParentViolation ,
10211
+ },
10212
+ {
10213
+ Skip : true ,
10214
+ Query : "create table child_dec_65_30 (d decimal(65,30), foreign key (d) references parent (d));" ,
10215
+ Expected : []sql.Row {
10216
+ {types .NewOkResult (0 )},
10217
+ },
10218
+ },
10219
+ {
10220
+ Skip : true ,
10221
+ Query : "insert into child_dec_65_30 values (1.23);" ,
10222
+ ExpectedErr : sql .ErrForeignKeyParentViolation ,
10223
+ },
10224
+ },
10225
+ },
10160
10226
10161
10227
// Date Tests
10162
10228
{
0 commit comments