Skip to content

Commit 3447ae4

Browse files
committed
Merge branch 'main' into spanner-lib
2 parents d1d3109 + c68065d commit 3447ae4

File tree

18 files changed

+268
-57
lines changed

18 files changed

+268
-57
lines changed

.github/workflows/integration-tests-on-emulator.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ on:
22
push:
33
branches: [ main ]
44
pull_request:
5-
branches: [ main ]
65
name: Integration tests on emulator
76
jobs:
87
test:

.github/workflows/samples.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
on:
22
pull_request:
3-
branches: [ main ]
43
name: Run Samples
54
jobs:
65
samples:

.github/workflows/snippets.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
on:
22
pull_request:
3-
branches: [ main ]
43
name: Run Snippets
54
jobs:
65
samples:

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ on:
22
push:
33
branches: [ main ]
44
pull_request:
5-
branches: [ main ]
65
name: Unit Tests
76
jobs:
87
test:

benchmarks/go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ replace github.com/googleapis/go-sql-spanner => ../
88

99
require (
1010
cloud.google.com/go v0.121.1
11-
cloud.google.com/go/spanner v1.81.0
11+
cloud.google.com/go/spanner v1.82.0
1212
github.com/google/uuid v1.6.0
13-
github.com/googleapis/go-sql-spanner v1.13.1
13+
github.com/googleapis/go-sql-spanner v1.13.2
1414
google.golang.org/api v0.233.0
15-
google.golang.org/grpc v1.72.0
15+
google.golang.org/grpc v1.72.1
1616
google.golang.org/protobuf v1.36.6
1717
)
1818

@@ -60,5 +60,5 @@ require (
6060
golang.org/x/time v0.11.0 // indirect
6161
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 // indirect
6262
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 // indirect
63-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250512202823-5a2f75b736a9 // indirect
63+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
6464
)

benchmarks/go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ cloud.google.com/go/shell v1.6.0/go.mod h1:oHO8QACS90luWgxP3N9iZVuEiSF84zNyLytb+
526526
cloud.google.com/go/spanner v1.41.0/go.mod h1:MLYDBJR/dY4Wt7ZaMIQ7rXOTLjYrmxLE/5ve9vFfWos=
527527
cloud.google.com/go/spanner v1.44.0/go.mod h1:G8XIgYdOK+Fbcpbs7p2fiprDw4CaZX63whnSMLVBxjk=
528528
cloud.google.com/go/spanner v1.45.0/go.mod h1:FIws5LowYz8YAE1J8fOS7DJup8ff7xJeetWEo5REA2M=
529-
cloud.google.com/go/spanner v1.81.0 h1:p2u1jX+VSz5cp9X5cehfBSDfezxpNzSTAcNHR3FEuCg=
530-
cloud.google.com/go/spanner v1.81.0/go.mod h1:3yqzHZvK52zLw10mNLG8MefCEYp3iRFJryTLf5u+mJg=
529+
cloud.google.com/go/spanner v1.82.0 h1:w9uO8RqEoBooBLX4nqV1RtgudyU2ZX780KTLRgeVg60=
530+
cloud.google.com/go/spanner v1.82.0/go.mod h1:BzybQHFQ/NqGxvE/M+/iU29xgutJf7Q85/4U9RWMto0=
531531
cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM=
532532
cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ=
533533
cloud.google.com/go/speech v1.8.0/go.mod h1:9bYIl1/tjsAnMgKGHKmBZzXKEkGgtU+MpdDPTE9f7y0=
@@ -1508,8 +1508,8 @@ google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 h1:1tXaIXCracvtsRx
15081508
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:49MsLSx0oWMOZqcpB3uL8ZOkAh1+TndpJ8ONoCBWiZk=
15091509
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 h1:vPV0tzlsK6EzEDHNNH5sa7Hs9bd7iXR7B1tSiPepkV0=
15101510
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:pKLAc5OolXC3ViWGI62vvC0n10CpwAtRcTNCFwTKBEw=
1511-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250512202823-5a2f75b736a9 h1:IkAfh6J/yllPtpYFU0zZN1hUPYdT0ogkBT/9hMxHjvg=
1512-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250512202823-5a2f75b736a9/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
1511+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34=
1512+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
15131513
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
15141514
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
15151515
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@@ -1551,8 +1551,8 @@ google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5v
15511551
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
15521552
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
15531553
google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
1554-
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
1555-
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
1554+
google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA=
1555+
google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
15561556
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
15571557
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
15581558
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=

conn.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,13 @@ func (c *conn) queryContext(ctx context.Context, query string, execOptions ExecO
758758
if err != nil {
759759
return nil, err
760760
}
761+
statementType := detectStatementType(query)
762+
// DDL statements are not supported in QueryContext so fail early.
763+
if statementType.statementType == statementTypeDdl {
764+
return nil, spanner.ToSpannerError(status.Errorf(codes.FailedPrecondition, "QueryContext does not support DDL statements, use ExecContext instead"))
765+
}
761766
var iter rowIterator
762767
if c.tx == nil {
763-
statementType := detectStatementType(query)
764768
if statementType.statementType == statementTypeDml {
765769
// Use a read/write transaction to execute the statement.
766770
var commitTs time.Time

conn_with_mockserver_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,65 @@ func TestIsolationLevelAutoCommit(t *testing.T) {
239239
}
240240
}
241241
}
242+
243+
func TestDDLUsingQueryContext(t *testing.T) {
244+
t.Parallel()
245+
246+
db, _, teardown := setupTestDBConnection(t)
247+
defer teardown()
248+
ctx := context.Background()
249+
250+
// DDL statements should not use the query context.
251+
_, err := db.QueryContext(ctx, "CREATE TABLE Foo (Bar STRING(100))")
252+
if err == nil {
253+
t.Fatal("expected error for DDL statement using QueryContext, got nil")
254+
}
255+
if g, w := err.Error(), `spanner: code = "FailedPrecondition", desc = "QueryContext does not support DDL statements, use ExecContext instead"`; g != w {
256+
t.Fatalf("error mismatch\n Got: %v\nWant: %v", g, w)
257+
}
258+
}
259+
260+
func TestDDLUsingQueryContextInReadOnlyTx(t *testing.T) {
261+
t.Parallel()
262+
263+
db, _, teardown := setupTestDBConnection(t)
264+
defer teardown()
265+
ctx := context.Background()
266+
tx, err := db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
267+
if err != nil {
268+
t.Fatal(err)
269+
}
270+
defer tx.Rollback()
271+
272+
// DDL statements should not use the query context in a read-only transaction.
273+
_, err = tx.QueryContext(ctx, "CREATE TABLE Foo (Bar STRING(100))")
274+
if err == nil {
275+
t.Fatal("expected error for DDL statement using QueryContext in read-only transaction, got nil")
276+
}
277+
if g, w := err.Error(), `spanner: code = "FailedPrecondition", desc = "QueryContext does not support DDL statements, use ExecContext instead"`; g != w {
278+
t.Fatalf("error mismatch\n Got: %v\nWant: %v", g, w)
279+
}
280+
}
281+
282+
func TestDDLUsingQueryContextInReadWriteTransaction(t *testing.T) {
283+
t.Parallel()
284+
285+
db, _, teardown := setupTestDBConnection(t)
286+
defer teardown()
287+
ctx := context.Background()
288+
289+
tx, err := db.BeginTx(ctx, &sql.TxOptions{})
290+
if err != nil {
291+
t.Fatal(err)
292+
}
293+
defer tx.Rollback()
294+
295+
// DDL statements should not use the query context in a read-write transaction.
296+
_, err = tx.QueryContext(ctx, "CREATE TABLE Foo (Bar STRING(100))")
297+
if err == nil {
298+
t.Fatal("expected error for DDL statement using QueryContext in read-write transaction, got nil")
299+
}
300+
if g, w := err.Error(), `spanner: code = "FailedPrecondition", desc = "QueryContext does not support DDL statements, use ExecContext instead"`; g != w {
301+
t.Fatalf("error mismatch\n Got: %v\nWant: %v", g, w)
302+
}
303+
}

driver.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,12 @@ func checkIsValidType(v driver.Value) bool {
10621062
case spanner.NullJSON:
10631063
case []spanner.NullJSON:
10641064
case spanner.GenericColumnValue:
1065+
case uuid.UUID:
1066+
case *uuid.UUID:
1067+
case []uuid.UUID:
1068+
case []*uuid.UUID:
1069+
case spanner.NullUUID:
1070+
case []spanner.NullUUID:
10651071
}
10661072
return true
10671073
}

0 commit comments

Comments
 (0)