Skip to content

Commit 3853635

Browse files
authored
Merge pull request #995 from dolthub/taylor/ignore-schemas
Tests for dolt_ignore per schema
2 parents 02d5011 + 7baffe0 commit 3853635

File tree

3 files changed

+127
-5
lines changed

3 files changed

+127
-5
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/PuerkitoBio/goquery v1.8.1
99
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
1010
github.com/cockroachdb/errors v1.7.5
11-
github.com/dolthub/dolt/go v0.40.5-0.20241122183655-9c1cc4c67583
11+
github.com/dolthub/dolt/go v0.40.5-0.20241122192009-068a8f446c04
1212
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d
1313
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
1414
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
214214
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
215215
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
216216
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
217-
github.com/dolthub/dolt/go v0.40.5-0.20241122183655-9c1cc4c67583 h1:dw0mBCmqoDFvh66OhTak5i1mwqpZzQ9B5cIi2VIQsSQ=
218-
github.com/dolthub/dolt/go v0.40.5-0.20241122183655-9c1cc4c67583/go.mod h1:aFv4w3D2nxTV1GD5OJ4/CEOnleES7E9AwLj59fjIxBo=
217+
github.com/dolthub/dolt/go v0.40.5-0.20241122192009-068a8f446c04 h1:jlhRiILaKsoBuqJoTbmzmAh+UeGRpN14LLN44Az5qbM=
218+
github.com/dolthub/dolt/go v0.40.5-0.20241122192009-068a8f446c04/go.mod h1:aFv4w3D2nxTV1GD5OJ4/CEOnleES7E9AwLj59fjIxBo=
219219
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d h1:gO9+wrmNHXukPNCO1tpfCcXIdMlW/qppbUStfLvqz/U=
220220
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20241119094239-f4e529af734d/go.mod h1:L5RDYZbC9BBWmoU2+TjTekeqqhFXX5EqH9ln00O0stY=
221221
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=

testing/go/dolt_tables_test.go

+124-2
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,37 @@ func TestUserSpaceDoltTables(t *testing.T) {
12911291
{"generated_exception", "f"},
12921292
},
12931293
},
1294+
{
1295+
Query: `SELECT * FROM public.dolt_ignore`,
1296+
Expected: []sql.Row{
1297+
{"generated_*", "t"},
1298+
{"generated_exception", "f"},
1299+
},
1300+
},
1301+
{
1302+
Query: `SELECT dolt_ignore.pattern FROM public.dolt_ignore`,
1303+
Expected: []sql.Row{
1304+
{"generated_*"},
1305+
{"generated_exception"},
1306+
},
1307+
},
1308+
{
1309+
Query: `SELECT name FROM other.dolt_ignore`,
1310+
ExpectedErr: "database schema not found",
1311+
},
1312+
{
1313+
Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING')`,
1314+
Expected: []sql.Row{
1315+
{"", "public.dolt_ignore", "added", 1, 1},
1316+
},
1317+
},
1318+
{
1319+
Query: `SELECT diff_type, from_pattern, to_pattern FROM dolt_diff('main', 'WORKING', 'dolt_ignore')`,
1320+
Expected: []sql.Row{
1321+
{"added", nil, "generated_*"},
1322+
{"added", nil, "generated_exception"},
1323+
},
1324+
},
12941325
{
12951326
Query: "CREATE TABLE foo (pk int);",
12961327
Expected: []sql.Row{},
@@ -1310,13 +1341,104 @@ func TestUserSpaceDoltTables(t *testing.T) {
13101341
{
13111342
Query: "SELECT * FROM dolt_status;",
13121343
Expected: []sql.Row{
1313-
{"dolt_ignore", 1, "new table"},
1344+
{"public.dolt_ignore", 1, "new table"},
1345+
{"public.foo", 1, "new table"},
1346+
{"public.generated_exception", 1, "new table"},
1347+
{"public.generated_foo", 0, "new table"},
1348+
},
1349+
},
1350+
{
1351+
Query: `CREATE SCHEMA newschema`,
1352+
Expected: []sql.Row{},
1353+
},
1354+
{
1355+
Query: "INSERT INTO newschema.dolt_ignore VALUES ('test_*', true)",
1356+
Expected: []sql.Row{},
1357+
},
1358+
{
1359+
Query: "SET search_path = 'newschema'",
1360+
Expected: []sql.Row{},
1361+
},
1362+
{
1363+
Query: `SELECT * FROM dolt_ignore`,
1364+
Expected: []sql.Row{
1365+
{"test_*", "t"},
1366+
},
1367+
},
1368+
{
1369+
// Should ignore generated_expected table in newschema but not in public
1370+
Query: "INSERT INTO dolt_ignore VALUES ('generated_exception', true)",
1371+
Expected: []sql.Row{},
1372+
},
1373+
{
1374+
Query: `SELECT * FROM dolt_ignore`,
1375+
Expected: []sql.Row{
1376+
{"generated_exception", "t"},
1377+
{"test_*", "t"},
1378+
},
1379+
},
1380+
{
1381+
Query: `SELECT * FROM newschema.dolt_ignore`,
1382+
Expected: []sql.Row{
1383+
{"generated_exception", "t"},
1384+
{"test_*", "t"},
1385+
},
1386+
},
1387+
{
1388+
Query: `SELECT * FROM public.dolt_ignore`,
1389+
Expected: []sql.Row{
1390+
{"generated_*", "t"},
1391+
{"generated_exception", "f"},
1392+
},
1393+
},
1394+
{
1395+
Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'dolt_ignore')`,
1396+
Expected: []sql.Row{
1397+
{"", "newschema.dolt_ignore", "added", 1, 1},
1398+
},
1399+
},
1400+
{
1401+
Query: `SELECT pattern FROM public.dolt_ignore`,
1402+
Expected: []sql.Row{
1403+
{"generated_*"},
1404+
{"generated_exception"},
1405+
},
1406+
},
1407+
{
1408+
Query: "CREATE TABLE foo (pk int);",
1409+
Expected: []sql.Row{},
1410+
},
1411+
{
1412+
Query: "CREATE TABLE test_foo (pk int);",
1413+
Expected: []sql.Row{},
1414+
},
1415+
{
1416+
Query: "CREATE TABLE generated_foo (pk int);",
1417+
Expected: []sql.Row{},
1418+
},
1419+
{
1420+
Query: "CREATE TABLE generated_exception (pk int);",
1421+
Expected: []sql.Row{},
1422+
},
1423+
{
1424+
Query: "SELECT dolt_add('-A');",
1425+
Expected: []sql.Row{{"{0}"}},
1426+
},
1427+
{
1428+
Query: "SELECT * FROM dolt_status ORDER BY table_name;",
1429+
Expected: []sql.Row{
1430+
{"newschema", 1, "new schema"},
1431+
{"newschema.dolt_ignore", 1, "new table"},
1432+
{"newschema.foo", 1, "new table"},
1433+
{"newschema.generated_exception", 0, "new table"},
1434+
{"newschema.generated_foo", 1, "new table"},
1435+
{"newschema.test_foo", 0, "new table"},
1436+
{"public.dolt_ignore", 1, "new table"},
13141437
{"public.foo", 1, "new table"},
13151438
{"public.generated_exception", 1, "new table"},
13161439
{"public.generated_foo", 0, "new table"},
13171440
},
13181441
},
1319-
// TODO: Test tables in different schemas
13201442
},
13211443
},
13221444
{

0 commit comments

Comments
 (0)