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

fixed client docs, added parse #787

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions cmd/kwil-cli/cmds/database/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,7 @@ func UnmarshalKf(file *os.File) (*types.Schema, error) {
return nil, fmt.Errorf("failed to read Kuneiform source file: %w", err)
}

res, err := parse.ParseAndValidate(source)
if err != nil {
return nil, fmt.Errorf("failed to parse Kuneiform source file: %w", err)
}
if res.Err() != nil {
return nil, fmt.Errorf("failed to parse Kuneiform source file: %w", res.Err())
}

return res.Schema, nil
return parse.Parse(source)
}

func UnmarshalJson(file *os.File) (*types.Schema, error) {
Expand Down
44 changes: 17 additions & 27 deletions core/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,41 +186,31 @@ the transaction is included in a block and executed, the database will become
available for use.

Before deploying a database, the schema definition is required. This is modeled
by the `core/types/transactions.Schema` type. We can parse a Kuneiform `.kf`
file using `github.com/kwilteam/kuneiform/kfparser` as follows:
by the `core/types.Schema` type. We can parse a Kuneiform `.kf`
file using `github.com/kwilteam/kwil-db/parse` as follows:

```go
import "github.com/kwilteam/kuneiform/kfparser"
import (
"github.com/kwilteam/kwil-db/parse"
ctypes "github.com/kwilteam/kwil-db/core/types/client"
)

// unmarshalKf parses the contents of a Kuneiform schema file.
func unmarshalKf(content string) (*transactions.Schema, error) {
astSchema, err := kfparser.Parse(content)
// parseAndDeploy parses a Kuneiform schema and deploys it.
// The Kuneiform schema should be passed in as a raw string.
// e.g. `database mydb; table my_table {...}`
func parseAndDeploy(client ctypes.Client, kf string) {
// Use the kuneiform packages to load the schema.
schema, err := parse.Parse([]byte(kf))
if err != nil {
return nil, fmt.Errorf("failed to parse file: %w", err)
log.Fatal(err)
}
schemaJSON, err := astSchema.ToJSON()

txHash, err := client.DeployDatabase(ctx, schema)
if err != nil {
return nil, fmt.Errorf("failed to marshal schema: %w", err)
log.Fatal(err)
}
var db transactions.Schema
return &db, json.Unmarshal(schemaJSON, &db)
}
```

In our example app, we can now use `DeployDatabase`:

```go
// Use the kuneiform packages to load the schema.
schema, err := unmarshalKf(testKf)
if err != nil {
log.Fatal(err)
}

txHash, err := cl.DeployDatabase(ctx, schema)
if err != nil {
log.Fatal(err)
fmt.Printf("DeployDatabase succeeded! txHash = %x", txHash)
}
fmt.Printf("DeployDatabase succeeded! txHash = %x", txHash)
```

If that succeeded, the database deployment transaction was successfully
Expand Down
9 changes: 2 additions & 7 deletions core/client/example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ replace github.com/kwilteam/kwil-db/core => ../..
replace github.com/kwilteam/kwil-db/parse => ../../../parse

require (
github.com/kwilteam/kwil-db/core v0.2.0-beta
github.com/kwilteam/kwil-db/core v0.2.0-beta.1
github.com/kwilteam/kwil-db/parse v0.2.0-beta
)

require (
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/cstockton/go-conv v1.0.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/go-ethereum v1.14.3 // indirect
Expand All @@ -31,12 +31,7 @@ require (
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
20 changes: 8 additions & 12 deletions core/client/example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOF
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg=
github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8=
github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
Expand All @@ -34,8 +36,6 @@ github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUp
github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs=
github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI=
github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
github.com/cstockton/go-conv v1.0.0 h1:zj/q/0MpQ/97XfiC9glWiohO8lhgR4TTnHYZifLTv6I=
github.com/cstockton/go-conv v1.0.0/go.mod h1:HuiHkkRgOA0IoBNPC7ysG7kNpjDYlgM7Kj62yQPxjy4=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
Expand Down Expand Up @@ -77,6 +77,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
Expand All @@ -86,8 +88,6 @@ github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqky
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pganalyze/pg_query_go/v5 v5.1.0 h1:MlxQqHZnvA3cbRQYyIrjxEjzo560P6MyTgtlaf3pmXg=
github.com/pganalyze/pg_query_go/v5 v5.1.0/go.mod h1:FsglvxidZsVN+Ltw3Ai6nTgPVcK2BPukH3jCDEqc1Ug=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
Expand All @@ -102,8 +102,8 @@ github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
Expand All @@ -126,23 +126,19 @@ golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434 h1:umK/Ey0QEzurTNlsV3R+MfxHAb78HCEX/IkuR+zH4WQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
21 changes: 1 addition & 20 deletions core/client/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package main
import (
"context"
"fmt"
"io"
"log"
"math/big"
"slices"
"strings"

"github.com/kwilteam/kwil-db/core/client"
"github.com/kwilteam/kwil-db/core/crypto"
Expand Down Expand Up @@ -96,7 +94,7 @@ func main() {

if !deployed { // need to deploy the "was_here" database
// Use the kuneiform packages to load the schema.
schema, err := unmarshalKf(strings.NewReader(testKf))
schema, err := parse.Parse([]byte(testKf))
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -227,20 +225,3 @@ action get_all() public view {
SELECT * FROM tags;
}
`

// go:embed test.json
// var testJSON []byte

func unmarshalKf(file io.Reader) (*types.Schema, error) {
source, err := io.ReadAll(file)
if err != nil {
return nil, fmt.Errorf("failed to read Kuneiform source file: %w", err)
}

parseRes, err := parse.ParseKuneiform(string(source))
if err != nil {
return nil, fmt.Errorf("failed to parse file: %w", err)
} // kfSchema := astSchema.(*schema.Schema); j, _ := json.Marshal(kfSchema)

return parseRes.Schema, nil
}
2 changes: 1 addition & 1 deletion internal/engine/integration/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func Test_Deployment(t *testing.T) {
// we intentionally use the bare kuneiform parser and don't
// perform extra checks because we want to test that the engine
// catches these errors
parsed, err := parse.ParseSchema([]byte(schema))
parsed, err := parse.ParseSchemaWithoutValidation([]byte(schema))
require.NoError(t, err)

err = global.CreateDataset(ctx, tx, parsed.Schema, &common.TransactionData{
Expand Down
7 changes: 3 additions & 4 deletions internal/engine/integration/procedure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,20 +623,19 @@ var satoshisUUID = &types.UUID{0x38, 0xeb, 0x77, 0xcb, 0x1e, 0x5a, 0x56, 0xc0, 0
func deploy(t *testing.T, global *execution.GlobalContext, db sql.DB, schema string) (dbid string) {
ctx := context.Background()

parsed, err := parse.ParseAndValidate([]byte(schema))
parsed, err := parse.Parse([]byte(schema))
require.NoError(t, err)
require.NoError(t, parsed.Err())

d := txData()
err = global.CreateDataset(ctx, db, parsed.Schema, &d)
err = global.CreateDataset(ctx, db, parsed, &d)
require.NoError(t, err)

// get dbid
dbs, err := global.ListDatasets(owner)
require.NoError(t, err)

for _, db := range dbs {
if db.Name == parsed.Schema.Name {
if db.Name == parsed.Name {
dbid = db.DBID
break
}
Expand Down
8 changes: 2 additions & 6 deletions internal/engine/integration/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,12 @@ func loadSchema(file string) (*types.Schema, error) {
return nil, err
}

db, err := parse.ParseAndValidate(d)
db, err := parse.Parse(d)
if err != nil {
return nil, err
}

if db.Err() != nil {
return nil, db.Err()
}

return db.Schema, nil
return db, nil
}

// deployAllSchemas deploys all schemas in the schemas directory.
Expand Down
26 changes: 23 additions & 3 deletions parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ import (
"github.com/kwilteam/kwil-db/parse/gen"
)

// Parse parses a Kuneiform schema. It will perform syntax, semantic, and type
// analysis, and return any errors.
func Parse(kf []byte) (*types.Schema, error) {
res, err := ParseAndValidate(kf)
if err != nil {
return nil, err
}

if res.Err() != nil {
return nil, res.Err()
}

return res.Schema, nil
}

// SchemaParseResult is the result of parsing a schema.
// It returns the resulting schema, as well as any expected errors that occurred during parsing.
// Unexpected errors will not be returned here, but instead in the function returning this type.
Expand All @@ -33,12 +48,17 @@ func (r *SchemaParseResult) Err() error {
}

// ParseAndValidate parses and validates an entire schema.
// It returns the parsed schema, as well as any errors that occurred during parsing and validation.
// It is meant to be used by parsing tools and the CLI. Most external users should use Parse instead.
func ParseAndValidate(kf []byte) (*SchemaParseResult, error) {
res, err := ParseSchema(kf)
res, err := ParseSchemaWithoutValidation(kf)
if err != nil {
return nil, err
}

// if there is a syntax error, we shouldn't continue with validation.
// We should still return a nil error, as the caller should read the error
// from the ParseErrs field.
if res.ParseErrs.Err() != nil {
return res, nil
}
Expand Down Expand Up @@ -66,10 +86,10 @@ func ParseAndValidate(kf []byte) (*SchemaParseResult, error) {
return res, nil
}

// ParseSchema parses a Kuneiform schema.
// ParseSchemaWithoutValidation parses a Kuneiform schema.
// It will not perform validations on the actions and procedures.
// Most users should use ParseAndValidate instead.
func ParseSchema(kf []byte) (res *SchemaParseResult, err error) {
func ParseSchemaWithoutValidation(kf []byte) (res *SchemaParseResult, err error) {
errLis, stream, parser, deferFn := setupParser(string(kf), "schema")

res = &SchemaParseResult{
Expand Down
2 changes: 1 addition & 1 deletion parse/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func Test_Kuneiform(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
res, err := parse.ParseSchema([]byte(tt.kf))
res, err := parse.ParseSchemaWithoutValidation([]byte(tt.kf))
require.NoError(t, err)
require.NoError(t, res.ParseErrs.Err())

Expand Down
11 changes: 4 additions & 7 deletions test/specifications/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ func (l *FileDatabaseSchemaLoader) Load(t *testing.T, targetSchema *testSchema)
t.Fatal("cannot open database schema file", err)
}

parseResult, err := parse.ParseAndValidate(d)
parseResult, err := parse.Parse(d)
if err != nil {
t.Fatal("cannot parse database schema", err)
}
if parseResult.Err() != nil {
t.Fatal("cannot parse database schema", parseResult.Err())
}

l.Modifier(parseResult.Schema)
return parseResult.Schema
l.Modifier(parseResult)
return parseResult
}

func (l *FileDatabaseSchemaLoader) LoadWithoutValidation(t *testing.T, targetSchema *testSchema) *types.Schema {
Expand All @@ -51,7 +48,7 @@ func (l *FileDatabaseSchemaLoader) LoadWithoutValidation(t *testing.T, targetSch
t.Fatal("cannot open database schema file", err)
}

db, err := parse.ParseSchema(d)
db, err := parse.ParseSchemaWithoutValidation(d)
if err != nil {
t.Fatal("cannot parse database schema", err)
}
Expand Down
11 changes: 1 addition & 10 deletions test/stress/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@ const (
)

func loadTestSchema() (*types.Schema, error) {
res, err := parse.ParseAndValidate([]byte(testScheme))
if err != nil {
return nil, err
}
if res.Err() != nil {
return nil, res.Err()
}

return res.Schema, nil

return parse.Parse([]byte(testScheme))
}

func init() {
Expand Down
Loading