Skip to content

Commit 6d3408f

Browse files
authored
Merge pull request #497 from tablelandnetwork/bcalza/bumpparser
Bumps the parser
2 parents a21d495 + c7012ad commit 6d3408f

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/sethvargo/go-limiter v0.7.2
2121
github.com/spf13/cobra v1.6.1
2222
github.com/stretchr/testify v1.8.2
23-
github.com/tablelandnetwork/sqlparser v0.0.0-20221230162331-b318f234cefd
23+
github.com/tablelandnetwork/sqlparser v0.0.0-20230328132500-785ebca8e351
2424
github.com/textileio/cli v1.0.2
2525
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0
2626
go.opentelemetry.io/otel v1.14.0

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,8 @@ github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5f
12951295
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
12961296
github.com/tablelandnetwork/sqlparser v0.0.0-20221230162331-b318f234cefd h1:AbpyzqlTban/UqJTrotlpWC9q/ePGU4qsrvqjoiLmG4=
12971297
github.com/tablelandnetwork/sqlparser v0.0.0-20221230162331-b318f234cefd/go.mod h1:S+M/v3Q8X+236kQxMQziFcLId2Cscb1LzW06IUVhljE=
1298+
github.com/tablelandnetwork/sqlparser v0.0.0-20230328132500-785ebca8e351 h1:aHuHicCezduOZVQXPXFM5MJ+h73caB2OUvVjGffzIsc=
1299+
github.com/tablelandnetwork/sqlparser v0.0.0-20230328132500-785ebca8e351/go.mod h1:S+M/v3Q8X+236kQxMQziFcLId2Cscb1LzW06IUVhljE=
12981300
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
12991301
github.com/textileio/cli v1.0.2 h1:qSp/x4d/9SZ93TxhgZnE5okRKqzqHqrzAwKAPjuPw50=
13001302
github.com/textileio/cli v1.0.2/go.mod h1:vTlCvvVyOmXXLwddCcBg3PDavfUsCkRBZoyr6Nu1lkc=

pkg/client/v1/client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func TestGetTableByID(t *testing.T) {
114114
require.Equal(t, "default 'foo'", table.Schema.Columns[0].Constraints[0])
115115

116116
require.Len(t, table.Schema.TableConstraints, 1)
117-
require.Equal(t, "check(zar > 0)", table.Schema.TableConstraints[0])
117+
require.Equal(t, "check(zar>0)", table.Schema.TableConstraints[0])
118118
})
119119
t.Run("status 404", func(t *testing.T) {
120120
calls := setup(t)

pkg/eventprocessor/impl/eventprocessor_replayhistory_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ func TestReplayProductionHistory(t *testing.T) {
3535
}
3636

3737
expectedStateHashes := map[tableland.ChainID]string{
38-
1: "ce4f083e256d3458a329b6cd1ba7d8e93d9703b3",
39-
5: "08af7e7055f266ea75d3b06350c47a52cfa59843",
40-
10: "2bce2d62e7f5eeadc4736f470ca2959b871e5d91",
41-
69: "643af9ad784444242c6ef415727203941a720197",
42-
137: "b5fb42f3538738ab5856abf9e3b2e38d82378ca4",
43-
420: "184800f533f4edd186853a85829fad8bc7802c4e",
44-
80001: "9336d3a3a36e57a86e4f95d3464048c954e46bc6",
45-
421613: "073727932afcee9a5dba19f43c023689ca855dc2",
38+
1: "bce26781eed109b8aaae2d1f688c134831fdf061",
39+
5: "913772facb72768ccd9db2ab4411296bbe166080",
40+
10: "1aa835eec9a9ac08cc2784d9d29df7fb15409d08",
41+
69: "fd1ba648c9406c0af321cb734eb203c742fff2a3",
42+
137: "fd1da780698b394a352b59e9b0c124f9cf010b67",
43+
420: "810a86b586e5333b453810305f0eabbf0bfb6934",
44+
80001: "13672494a659c31b46a8fa3d6973b7671a1d567b",
45+
421613: "d58fd380066628fa92fd8a87831ea744b9ba1d8b",
4646
}
4747

4848
historyDBURI := getHistoryDBURI(t)

pkg/parsing/impl/validator_test.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ func TestReadRunSQL(t *testing.T) {
3838
},
3939
{
4040
name: "valid defined rows",
41-
query: "select row1, row2 from zoo_4321 where a = b",
41+
query: "select row1,row2 from zoo_4321 where a=b",
4242
expErrType: nil,
4343
},
4444

4545
// Allow joins and sub-queries
4646
{
4747
name: "with join",
48-
query: "select * from foo_1 join bar_2 on a = b",
48+
query: "select * from foo_1 join bar_2 on a=b",
4949
expErrType: nil,
5050
},
5151
{
5252
name: "with subselect",
53-
query: "select * from foo_1 where a in (select b from zoo_5)",
53+
query: "select * from foo_1 where a in(select b from zoo_5)",
5454
expErrType: nil,
5555
},
5656
{
5757
name: "column with subquery",
58-
query: "select (select * from bar_2 limit 1) from foo_3",
58+
query: "select(select * from bar_2 limit 1)from foo_3",
5959
expErrType: nil,
6060
},
6161
{
6262
name: "select with complex subqueries in function arguments",
63-
query: `select json_object('name', '#' || rigs.id, 'external_url', 'https://rigs.tableland.xyz/' || rigs.id, 'attributes', json_array(json_object('trait_type', 'Fleet', 'value', rigs.fleet), json_object('trait_type', 'Chassis', 'value', rigs.chassis), json_object('trait_type', 'Wheels', 'value', rigs.wheels), json_object('trait_type', 'Background', 'value', rigs.background), json_object('trait_type', (select name from badges_2 where badges.rig_id = rigs.id and position = 1 limit 1), 'value', (select image from badges_2 where badges.rig_id = rigs.id and position = 1 limit 1)))) from rigs_1`, // nolint
63+
query: `select json_object('name','#'||rigs.id,'external_url','https://rigs.tableland.xyz/'||rigs.id,'attributes',json_array(json_object('trait_type','Fleet','value',rigs.fleet),json_object('trait_type','Chassis','value',rigs.chassis),json_object('trait_type','Wheels','value',rigs.wheels),json_object('trait_type','Background','value',rigs.background),json_object('trait_type',(select name from badges_2 where badges.rig_id=rigs.id and position=1 limit 1),'value',(select image from badges_2 where badges.rig_id=rigs.id and position=1 limit 1))))from rigs_1`, // nolint
6464
expErrType: nil,
6565
},
6666

@@ -574,9 +574,9 @@ func TestCreateTableResult(t *testing.T) {
574574
// echo -n bar:INT | shasum -a 256
575575
expStructureHash: "5d70b398f938650871dd0d6d421e8d1d0c89fe9ed6c8a817c97e951186da7172",
576576
expRawQueries: []rawQueryTableID{
577-
{id: 1, rawQuery: "create table my_10_nth_table_1337_1 (bar int) strict"},
578-
{id: 42, rawQuery: "create table my_10_nth_table_1337_42 (bar int) strict"},
579-
{id: 2929392, rawQuery: "create table my_10_nth_table_1337_2929392 (bar int) strict"},
577+
{id: 1, rawQuery: "create table my_10_nth_table_1337_1(bar int)strict"},
578+
{id: 42, rawQuery: "create table my_10_nth_table_1337_42(bar int)strict"},
579+
{id: 2929392, rawQuery: "create table my_10_nth_table_1337_2929392(bar int)strict"},
580580
},
581581
},
582582
{
@@ -588,8 +588,8 @@ func TestCreateTableResult(t *testing.T) {
588588
// echo -n bar:INT | shasum -a 256
589589
expStructureHash: "5d70b398f938650871dd0d6d421e8d1d0c89fe9ed6c8a817c97e951186da7172",
590590
expRawQueries: []rawQueryTableID{
591-
{id: 1, rawQuery: "create table _1337_1 (bar int) strict"},
592-
{id: 42, rawQuery: "create table _1337_42 (bar int) strict"},
591+
{id: 1, rawQuery: "create table _1337_1(bar int)strict"},
592+
{id: 42, rawQuery: "create table _1337_42(bar int)strict"},
593593
},
594594
},
595595
{
@@ -603,9 +603,9 @@ func TestCreateTableResult(t *testing.T) {
603603
// echo -n name:TEXT,age:INT,fav_color:TEXT | shasum -a 256
604604
expStructureHash: "f45023b189891ad781070ac05374d4e7d7ec7ae007cfd836791c36d609ba7ddd",
605605
expRawQueries: []rawQueryTableID{
606-
{id: 1, rawQuery: "create table person_1337_1 (name text, age int, fav_color text) strict"},
607-
{id: 42, rawQuery: "create table person_1337_42 (name text, age int, fav_color text) strict"},
608-
{id: 2929392, rawQuery: "create table person_1337_2929392 (name text, age int, fav_color text) strict"},
606+
{id: 1, rawQuery: "create table person_1337_1(name text,age int,fav_color text)strict"},
607+
{id: 42, rawQuery: "create table person_1337_42(name text,age int,fav_color text)strict"},
608+
{id: 2929392, rawQuery: "create table person_1337_2929392(name text,age int,fav_color text)strict"},
609609
},
610610
},
611611
}
@@ -689,16 +689,16 @@ func TestGetWriteStatements(t *testing.T) {
689689
name: "double update",
690690
query: "update foo_1337_100 set a=1;update foo_1337_100 set b=2;",
691691
expectedStmts: []string{
692-
"update foo_1337_100 set a = 1",
693-
"update foo_1337_100 set b = 2",
692+
"update foo_1337_100 set a=1",
693+
"update foo_1337_100 set b=2",
694694
},
695695
},
696696
{
697697
name: "insert update",
698698
query: "insert into foo_1337_1 values (1);update foo_1337_1 set b=2;",
699699
expectedStmts: []string{
700-
"insert into foo_1337_1 values (1)",
701-
"update foo_1337_1 set b = 2",
700+
"insert into foo_1337_1 values(1)",
701+
"update foo_1337_1 set b=2",
702702
},
703703
},
704704
}
@@ -737,7 +737,7 @@ func TestGetGrantStatementRolesAndPrivileges(t *testing.T) {
737737
query: "grant insert, UPDATE on a_1337_100 to '0xd43c59d5694ec111eb9e986c233200b14249558d';",
738738
roles: []common.Address{common.HexToAddress("0xd43c59d5694ec111eb9e986c233200b14249558d")},
739739
privileges: []tableland.Privilege{tableland.PrivInsert, tableland.PrivUpdate},
740-
expectedStmt: "grant insert, update on a_1337_100 to '0xd43c59d5694ec111eb9e986c233200b14249558d'",
740+
expectedStmt: "grant insert,update on a_1337_100 to '0xd43c59d5694ec111eb9e986c233200b14249558d'",
741741
},
742742

743743
{
@@ -788,13 +788,13 @@ func TestWriteStatementAddWhereClause(t *testing.T) {
788788
name: "no-where-clause",
789789
query: "UPDATE foo_1337_10 SET id = 1",
790790
whereClause: "bar = 1",
791-
expQuery: "update foo_1337_10 set id = 1 where bar = 1",
791+
expQuery: "update foo_1337_10 set id=1 where bar=1",
792792
},
793793
{
794794
name: "with-where-clause",
795795
query: "update foo_1337_10 set id = 1 where bar = 1",
796796
whereClause: "c in (1, 2)",
797-
expQuery: "update foo_1337_10 set id = 1 where bar = 1 and c in (1, 2)",
797+
expQuery: "update foo_1337_10 set id=1 where bar=1 and c in(1,2)",
798798
},
799799
}
800800

@@ -840,7 +840,7 @@ func TestWriteStatementAddReturningClause(t *testing.T) {
840840

841841
sql, err := ws.GetQuery(nil)
842842
require.NoError(t, err)
843-
require.Equal(t, "insert into foo_1337_1 values ('bar') returning (rowid)", sql)
843+
require.Equal(t, "insert into foo_1337_1 values('bar')returning(rowid)", sql)
844844
})
845845

846846
t.Run("update-add-returning", func(t *testing.T) {
@@ -859,7 +859,7 @@ func TestWriteStatementAddReturningClause(t *testing.T) {
859859

860860
sql, err := ws.GetQuery(nil)
861861
require.NoError(t, err)
862-
require.Equal(t, "update foo_1337_1 set foo = 'bar' returning (rowid)", sql)
862+
require.Equal(t, "update foo_1337_1 set foo='bar' returning(rowid)", sql)
863863
})
864864

865865
t.Run("delete-add-returning-error", func(t *testing.T) {

0 commit comments

Comments
 (0)