File tree 3 files changed +7
-30
lines changed
3 files changed +7
-30
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ import (
30
30
var _ semantics.SchemaInformation = (* SchemaInfo )(nil )
31
31
32
32
type (
33
+ // SchemaInfo is a simple implementation of semantics.SchemaInformation
34
+ // It will claim that any table that is asked for is present in the schema, with no columns specified and authoratative columns set to false
35
+ // it has a createTableHandler that can be used to populate the schema if the
36
+ // query log contains the CREATE TABLE statements
33
37
SchemaInfo struct {
34
38
KsName string
35
39
Tables map [string ]Columns
Original file line number Diff line number Diff line change 55
55
func Run (cfg Config ) {
56
56
s := & state {
57
57
parser : sqlparser .NewTestParser (),
58
- si : getFakeSchema () ,
58
+ si : & keys. SchemaInfo {} ,
59
59
txs : newTxSignatureMap (),
60
60
}
61
61
s .run (os .Stdout , cfg )
@@ -368,31 +368,3 @@ func (s *state) getAutocommitGuess(cfg Config) bool {
368
368
})
369
369
return defaultAutocommit
370
370
}
371
-
372
- func getFakeSchema () * keys.SchemaInfo {
373
- // WIP: dummy data
374
- // TODO: Use real schema information data with the 'vt schema' JSON output
375
- si := & keys.SchemaInfo {
376
- Tables : map [string ]keys.Columns {
377
- "tblA" : {
378
- {Name : sqlparser .NewIdentifierCI ("apa" )},
379
- {Name : sqlparser .NewIdentifierCI ("foo" )},
380
- {Name : sqlparser .NewIdentifierCI ("id" )},
381
- },
382
- "tblB" : {
383
- {Name : sqlparser .NewIdentifierCI ("monkey" )},
384
- {Name : sqlparser .NewIdentifierCI ("bar" )},
385
- {Name : sqlparser .NewIdentifierCI ("id" )},
386
- },
387
- "user" : {
388
- {Name : sqlparser .NewIdentifierCI ("id" )},
389
- {Name : sqlparser .NewIdentifierCI ("name" )},
390
- },
391
- "user_extra" : {
392
- {Name : sqlparser .NewIdentifierCI ("user_id" )},
393
- {Name : sqlparser .NewIdentifierCI ("age" )},
394
- },
395
- },
396
- }
397
- return si
398
- }
Original file line number Diff line number Diff line change @@ -26,13 +26,14 @@ import (
26
26
"vitess.io/vitess/go/vt/sqlparser"
27
27
28
28
"github.com/vitessio/vt/go/data"
29
+ "github.com/vitessio/vt/go/keys"
29
30
)
30
31
31
32
func TestRun (t * testing.T ) {
32
33
sb := & strings.Builder {}
33
34
s := & state {
34
35
parser : sqlparser .NewTestParser (),
35
- si : getFakeSchema () ,
36
+ si : & keys. SchemaInfo {} ,
36
37
txs : newTxSignatureMap (),
37
38
}
38
39
s .run (sb , Config {
You can’t perform that action at this time.
0 commit comments