Skip to content

Commit 82d22c0

Browse files
elianddbclaude
andcommitted
Address PR review feedback from jycor
- Use SqlMode struct instead of manual string parsing in isStrictMode - Leverage LoadSqlMode() and ModeEnabled() methods for proper SQL mode detection - Unskip enum default validation tests that now work with our implementation - Update expected error types to ErrInvalidColumnDefaultValue for enum defaults 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent dd2b3a9 commit 82d22c0

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

enginetest/queries/script_queries.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8465,23 +8465,20 @@ where
84658465
ExpectedErr: sql.ErrIncompatibleDefaultType,
84668466
},
84678467
{
8468-
Skip: true,
84698468
Query: "create table bad (e enum('a') default 0);",
8470-
ExpectedErr: sql.ErrIncompatibleDefaultType,
8469+
ExpectedErr: sql.ErrInvalidColumnDefaultValue,
84718470
},
84728471
{
84738472
Query: "create table bad (e enum('a') default '');",
84748473
ExpectedErr: sql.ErrIncompatibleDefaultType,
84758474
},
84768475
{
8477-
Skip: true,
84788476
Query: "create table bad (e enum('a') default '1');",
8479-
ExpectedErr: sql.ErrIncompatibleDefaultType,
8477+
ExpectedErr: sql.ErrInvalidColumnDefaultValue,
84808478
},
84818479
{
8482-
Skip: true,
84838480
Query: "create table bad (e enum('a') default 1);",
8484-
ExpectedErr: sql.ErrIncompatibleDefaultType,
8481+
ExpectedErr: sql.ErrInvalidColumnDefaultValue,
84858482
},
84868483

84878484
{

sql/types/enum.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,8 @@ func (t EnumType) Convert(ctx context.Context, v interface{}) (interface{}, sql.
219219
// isStrictMode checks if STRICT_TRANS_TABLES or STRICT_ALL_TABLES is enabled
220220
func (t EnumType) isStrictMode(ctx context.Context) bool {
221221
if sqlCtx, ok := ctx.(*sql.Context); ok {
222-
sysVal, err := sqlCtx.GetSessionVariable(sqlCtx, "sql_mode")
223-
if err == nil {
224-
if sqlMode, ok := sysVal.(string); ok {
225-
return strings.Contains(sqlMode, "STRICT_TRANS_TABLES") || strings.Contains(sqlMode, "STRICT_ALL_TABLES")
226-
}
227-
}
222+
sqlMode := sql.LoadSqlMode(sqlCtx)
223+
return sqlMode.ModeEnabled("STRICT_TRANS_TABLES") || sqlMode.ModeEnabled("STRICT_ALL_TABLES")
228224
}
229225
return false
230226
}

0 commit comments

Comments
 (0)