From 49ae19ff9cd204a6adcb65fea2d2bf1c11150494 Mon Sep 17 00:00:00 2001 From: Bruno Calza Date: Tue, 2 May 2023 19:52:23 -0300 Subject: [PATCH] fix table's name validation Signed-off-by: Bruno Calza --- go.mod | 2 +- go.sum | 4 ++++ .../impl/eventprocessor_replayhistory_test.go | 4 ++-- pkg/parsing/impl/validator_test.go | 8 ++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index baffa937..5af46b53 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/sethvargo/go-limiter v0.7.2 github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.2 - github.com/tablelandnetwork/sqlparser v0.0.0-20230420192826-7c549ca44bf8 + github.com/tablelandnetwork/sqlparser v0.0.0-20230502232446-6e10f18895a3 github.com/textileio/cli v1.0.2 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0 go.opentelemetry.io/otel v1.14.0 diff --git a/go.sum b/go.sum index ea588cdc..22b936c0 100644 --- a/go.sum +++ b/go.sum @@ -1299,6 +1299,10 @@ github.com/tablelandnetwork/sqlparser v0.0.0-20230328132500-785ebca8e351 h1:aHuH github.com/tablelandnetwork/sqlparser v0.0.0-20230328132500-785ebca8e351/go.mod h1:S+M/v3Q8X+236kQxMQziFcLId2Cscb1LzW06IUVhljE= github.com/tablelandnetwork/sqlparser v0.0.0-20230420192826-7c549ca44bf8 h1:mC58HOJfkfPsqetYd4hpCp0ey5qb9/ZkIRZEx+d2b4U= github.com/tablelandnetwork/sqlparser v0.0.0-20230420192826-7c549ca44bf8/go.mod h1:S+M/v3Q8X+236kQxMQziFcLId2Cscb1LzW06IUVhljE= +github.com/tablelandnetwork/sqlparser v0.0.0-20230502223534-5872144545c4 h1:YjROwj4D7PXJbKCNdpTZJM8TpfKhdFgdzzjh3RTY1wo= +github.com/tablelandnetwork/sqlparser v0.0.0-20230502223534-5872144545c4/go.mod h1:S+M/v3Q8X+236kQxMQziFcLId2Cscb1LzW06IUVhljE= +github.com/tablelandnetwork/sqlparser v0.0.0-20230502232446-6e10f18895a3 h1:QyOUHf3JEz3p3JrijVHRggaPKahuJLuxyslxlMmuXAc= +github.com/tablelandnetwork/sqlparser v0.0.0-20230502232446-6e10f18895a3/go.mod h1:S+M/v3Q8X+236kQxMQziFcLId2Cscb1LzW06IUVhljE= github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I= github.com/textileio/cli v1.0.2 h1:qSp/x4d/9SZ93TxhgZnE5okRKqzqHqrzAwKAPjuPw50= github.com/textileio/cli v1.0.2/go.mod h1:vTlCvvVyOmXXLwddCcBg3PDavfUsCkRBZoyr6Nu1lkc= diff --git a/pkg/eventprocessor/impl/eventprocessor_replayhistory_test.go b/pkg/eventprocessor/impl/eventprocessor_replayhistory_test.go index 357cb29f..e09b1058 100644 --- a/pkg/eventprocessor/impl/eventprocessor_replayhistory_test.go +++ b/pkg/eventprocessor/impl/eventprocessor_replayhistory_test.go @@ -38,12 +38,12 @@ func TestReplayProductionHistory(t *testing.T) { expectedStateHashes := map[tableland.ChainID]string{ 1: "bce26781eed109b8aaae2d1f688c134831fdf061", - 5: "f141373c03aee3a74595538abba81cd1c3755f63", + 5: "21684ad97813634841393a097436e397de96692f", 10: "1aa835eec9a9ac08cc2784d9d29df7fb15409d08", 69: "fd1ba648c9406c0af321cb734eb203c742fff2a3", 137: "fd1da780698b394a352b59e9b0c124f9cf010b67", 420: "639dda72b6e4a5a8ef7ceb2b734e0b6ecc241407", - 80001: "f5bc53afc7525e9ff1f337bad8e9d4e9cb1ad111", + 80001: "50d477f69179aa0b027c8df7661666c7b5676699", 421613: "d58fd380066628fa92fd8a87831ea744b9ba1d8b", } diff --git a/pkg/parsing/impl/validator_test.go b/pkg/parsing/impl/validator_test.go index 660a3f9a..bdacf3a8 100644 --- a/pkg/parsing/impl/validator_test.go +++ b/pkg/parsing/impl/validator_test.go @@ -530,6 +530,14 @@ func TestCreateTableChecks(t *testing.T) { chainID: 1337, expErrType: ptr2ErrKeywordIsNotAllowed(), }, + + // Table name + { + name: "enclosed table name", + query: "CREATE TABLE [users_31337] (id integer NOT NULL)", + chainID: 31337, + expErrType: nil, + }, } for _, it := range tests {