-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
test: make it easier to run tests without a main keyspace #17501
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package vschemawrapper | |
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
|
@@ -275,17 +276,6 @@ func (vw *VSchemaWrapper) FindTableOrVindex(tab sqlparser.TableName) (*vindexes. | |
return vw.Vcursor.FindTableOrVindex(tab) | ||
} | ||
|
||
func (vw *VSchemaWrapper) getfirstKeyspace() (ks *vindexes.Keyspace) { | ||
var f string | ||
for name, schema := range vw.V.Keyspaces { | ||
if f == "" || f > name { | ||
f = name | ||
ks = schema.Keyspace | ||
} | ||
} | ||
return | ||
} | ||
|
||
func (vw *VSchemaWrapper) getActualKeyspace() string { | ||
if vw.Keyspace == nil { | ||
return "" | ||
|
@@ -301,15 +291,24 @@ func (vw *VSchemaWrapper) getActualKeyspace() string { | |
} | ||
|
||
func (vw *VSchemaWrapper) SelectedKeyspace() (*vindexes.Keyspace, error) { | ||
return vw.V.Keyspaces["main"].Keyspace, nil | ||
return vw.AnyKeyspace() | ||
} | ||
|
||
func (vw *VSchemaWrapper) AnyKeyspace() (*vindexes.Keyspace, error) { | ||
return vw.SelectedKeyspace() | ||
ks, found := vw.V.Keyspaces["main"] | ||
if found { | ||
Comment on lines
-308
to
+300
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
return ks.Keyspace, nil | ||
} | ||
|
||
for _, ks := range vw.V.Keyspaces { | ||
return ks.Keyspace, nil | ||
} | ||
|
||
return nil, errors.New("no keyspace found in vschema") | ||
} | ||
|
||
func (vw *VSchemaWrapper) FirstSortedKeyspace() (*vindexes.Keyspace, error) { | ||
return vw.V.Keyspaces["main"].Keyspace, nil | ||
return vw.AnyKeyspace() | ||
} | ||
Comment on lines
-312
to
321
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
func (vw *VSchemaWrapper) TargetString() string { | ||
|
@@ -344,12 +343,12 @@ func (vw *VSchemaWrapper) IsViewsEnabled() bool { | |
|
||
// FindMirrorRule finds the mirror rule for the requested keyspace, table | ||
// name, and the tablet type in the VSchema. | ||
func (vs *VSchemaWrapper) FindMirrorRule(tab sqlparser.TableName) (*vindexes.MirrorRule, error) { | ||
func (vw *VSchemaWrapper) FindMirrorRule(tab sqlparser.TableName) (*vindexes.MirrorRule, error) { | ||
destKeyspace, destTabletType, _, err := topoproto.ParseDestination(tab.Qualifier.String(), topodatapb.TabletType_PRIMARY) | ||
if err != nil { | ||
return nil, err | ||
} | ||
mirrorRule, err := vs.V.FindMirrorRule(destKeyspace, tab.Name.String(), destTabletType) | ||
mirrorRule, err := vw.V.FindMirrorRule(destKeyspace, tab.Name.String(), destTabletType) | ||
Comment on lines
356
to
+360
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. possibly duplicate logic, |
||
if err != nil { | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
vw. Vcursor