Skip to content

Commit

Permalink
Fix dolt_ignore, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbantle22 committed Nov 21, 2024
1 parent 72cfcb3 commit f78677b
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
56 changes: 56 additions & 0 deletions server/tables/dtables/ignore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2024 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dtables

import (
"fmt"

"github.com/dolthub/go-mysql-server/sql"

pgtypes "github.com/dolthub/doltgresql/server/types"

"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/store/val"
)

func getDoltIgnoreSchema() sql.Schema {
return []*sql.Column{
{Name: "pattern", Type: pgtypes.Text, Source: doltdb.IgnoreTableName, PrimaryKey: true},
{Name: "ignored", Type: pgtypes.Bool, Source: doltdb.IgnoreTableName, PrimaryKey: false, Nullable: false},
}
}

func convertTupleToIgnoreBoolean(valueDesc val.TupleDesc, valueTuple val.Tuple) (bool, error) {
extendedTuple := val.NewTupleDescriptorWithArgs(
val.TupleDescriptorArgs{Comparator: valueDesc.Comparator(), Handlers: valueDesc.Handlers},
val.Type{Enc: val.ExtendedEnc, Nullable: false},
)
if !valueDesc.Equals(extendedTuple) {
return false, fmt.Errorf("dolt_ignore had unexpected value type, this should never happen")
}
extended, ok := valueDesc.GetExtended(0, valueTuple)
if !ok {
return false, fmt.Errorf("could not read boolean")
}
val, err := valueDesc.Handlers[0].DeserializeValue(extended)
if err != nil {
return false, err
}
ignore, ok := val.(bool)
if !ok {
return false, fmt.Errorf("could not read boolean")
}
return ignore, nil
}
3 changes: 2 additions & 1 deletion server/tables/dtables/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ func Init() {

// Schemas
dtables.GetDocsSchema = getDocsSchema
// dtables.GetDoltIgnoreSchema = getDoltIgnoreSchema
dtables.GetDoltIgnoreSchema = getDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (ubuntu-22.04)

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Run Staticcheck

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (macos-latest)

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: dtables.GetDoltIgnoreSchema

Check failure on line 47 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: dtables.GetDoltIgnoreSchema
dprocedures.GetDoltRebaseSystemTableSchema = getRebaseSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (ubuntu-22.04)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Run Staticcheck

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (macos-latest)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

Check failure on line 48 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: dprocedures.GetDoltRebaseSystemTableSchema

// Conversions
doltdb.ConvertTupleToIgnoreBoolean = convertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (ubuntu-22.04)

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Run Staticcheck

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (macos-latest)

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: doltdb.ConvertTupleToIgnoreBoolean

Check failure on line 51 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: doltdb.ConvertTupleToIgnoreBoolean
sqle.ConvertRebasePlanStepToRow = convertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (ubuntu-22.04)

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Run Staticcheck

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (macos-latest)

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: sqle.ConvertRebasePlanStepToRow

Check failure on line 52 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: sqle.ConvertRebasePlanStepToRow
sqle.ConvertRowToRebasePlanStep = convertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (ubuntu-22.04)

undefined: sqle.ConvertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: sqle.ConvertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Run Staticcheck

undefined: sqle.ConvertRowToRebasePlanStep (compile)

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: sqle.ConvertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / Bats tests (macos-latest)

undefined: sqle.ConvertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (macos-latest)

undefined: sqle.ConvertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

undefined: sqle.ConvertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: sqle.ConvertRowToRebasePlanStep

Check failure on line 53 in server/tables/dtables/init.go

View workflow job for this annotation

GitHub Actions / test (windows-latest)

undefined: sqle.ConvertRowToRebasePlanStep
}
Expand Down
47 changes: 47 additions & 0 deletions testing/go/dolt_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,53 @@ func TestUserSpaceDoltTables(t *testing.T) {
},
},
},
{
Name: "dolt ignore",
SetUpScript: []string{},
Assertions: []ScriptTestAssertion{
{
Query: `SELECT * FROM dolt_ignore`,
Expected: []sql.Row{},
},
{
Query: "INSERT INTO dolt_ignore VALUES ('generated_*', true), ('generated_exception', false)",
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM dolt_ignore`,
Expected: []sql.Row{
{"generated_*", "t"},
{"generated_exception", "f"},
},
},
{
Query: "CREATE TABLE foo (pk int);",
Expected: []sql.Row{},
},
{
Query: "CREATE TABLE generated_foo (pk int);",
Expected: []sql.Row{},
},
{
Query: "CREATE TABLE generated_exception (pk int);",
Expected: []sql.Row{},
},
{
Query: "SELECT dolt_add('-A');",
Expected: []sql.Row{{"{0}"}},
},
{
Query: "SELECT * FROM dolt_status;",
Expected: []sql.Row{
{"dolt_ignore", 1, "new table"},
{"public.foo", 1, "new table"},
{"public.generated_exception", 1, "new table"},
{"public.generated_foo", 0, "new table"},
},
},
// TODO: Test tables in different schemas
},
},
{
Name: "dolt log",
Assertions: []ScriptTestAssertion{
Expand Down

0 comments on commit f78677b

Please sign in to comment.