diff --git a/dialect/sql/builder.go b/dialect/sql/builder.go index 475418524..d12e57792 100644 --- a/dialect/sql/builder.go +++ b/dialect/sql/builder.go @@ -2363,6 +2363,9 @@ func WithLockClause(clause string) LockOption { // For sets the lock configuration for suffixing the `SELECT` // statement with the `FOR [SHARE | UPDATE] ...` clause. func (s *Selector) For(l LockStrength, opts ...LockOption) *Selector { + if s.Dialect() == dialect.SQLite { + s.AddError(errors.New("sql: SELECT .. FOR UPDATE/SHARE not supported in SQLite")) + } s.lock = &LockOptions{Strength: l} for _, opt := range opts { opt(s.lock) diff --git a/dialect/sql/builder_test.go b/dialect/sql/builder_test.go index e5e9abec3..81c3b5ee4 100644 --- a/dialect/sql/builder_test.go +++ b/dialect/sql/builder_test.go @@ -1667,6 +1667,14 @@ func TestSelectWithLock(t *testing.T) { Query() require.Equal(t, "SELECT * FROM `users` WHERE `id` = ? LOCK IN SHARE MODE", query) require.Equal(t, 20, args[0]) + + s := Dialect(dialect.SQLite). + Select(). + From(Table("users")). + Where(EQ("id", 1)). + ForUpdate() + s.Query() + require.EqualError(t, s.Err(), "sql: SELECT .. FOR UPDATE/SHARE not supported in SQLite") } func TestSelector_UnionOrderBy(t *testing.T) {