Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number conversion #378

Merged
merged 12 commits into from
Apr 1, 2021
2 changes: 2 additions & 0 deletions database/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (c *Catalog) Load(tx *Transaction) error {
FieldName: "table_name",
},
},
Type: document.TextValue,
IsPrimaryKey: true,
},
},
Expand All @@ -58,6 +59,7 @@ func (c *Catalog) Load(tx *Transaction) error {
FieldName: "index_name",
},
},
Type: document.TextValue,
IsPrimaryKey: true,
},
},
Expand Down
18 changes: 18 additions & 0 deletions database/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"errors"
"testing"

"github.com/genjidb/genji"
"github.com/genjidb/genji/database"
"github.com/genjidb/genji/document"
"github.com/genjidb/genji/testutil"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -662,3 +664,19 @@ func TestReIndexAll(t *testing.T) {
require.Equal(t, clone, catalog)
})
}

func TestReadOnlyTables(t *testing.T) {
db, err := genji.Open(":memory:")
require.NoError(t, err)
defer db.Close()

doc, err := db.QueryDocument(`CREATE TABLE foo; SELECT * FROM __genji_tables`)
require.NoError(t, err)

testutil.RequireDocJSONEq(t, doc, `{"field_constraints": [], "read_only":false, "store_name":"dAE=", "table_name":"foo"}`)

doc, err = db.QueryDocument(`CREATE INDEX idx_foo_a ON foo(a); SELECT * FROM __genji_indexes`)
require.NoError(t, err)

testutil.RequireDocJSONEq(t, doc, `{"index_name":"idx_foo_a", "path":["a"], "table_name":"foo", "unique":false}`)
}
Loading