Skip to content

Commit

Permalink
Rename RewriteQuery->AddTablePrefix
Browse files Browse the repository at this point in the history
Signed-off-by: sashayakovtseva <[email protected]>
  • Loading branch information
sashayakovtseva committed Feb 7, 2024
1 parent 3fe0b7e commit 63287c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/datastore/ydb/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var bytesPool = sync.Pool{
},
}

func RewriteQuery(query string, tablePathPrefix string) string {
func AddTablePrefix(query string, tablePathPrefix string) string {
if tablePathPrefix == "" {
return query
}
Expand Down
4 changes: 2 additions & 2 deletions internal/datastore/ydb/migrations/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (d *YDBDriver) Version(ctx context.Context) (string, error) {
_, res, err := s.Execute(
ctx,
table.DefaultTxControl(),
common.RewriteQuery(queryLoadVersion, d.tablePathPrefix),
common.AddTablePrefix(queryLoadVersion, d.tablePathPrefix),
nil,
)
if err != nil {
Expand Down Expand Up @@ -114,7 +114,7 @@ func (d *YDBDriver) Version(ctx context.Context) (string, error) {
func (d *YDBDriver) WriteVersion(ctx context.Context, tx TxActorWithOptions, version, _ string) error {
res, err := tx.tx.Execute(
ctx,
common.RewriteQuery(queryWriteVersion, tx.opts.tablePathPrefix),
common.AddTablePrefix(queryWriteVersion, tx.opts.tablePathPrefix),
table.NewQueryParameters(
table.ValueParam("$newVersion", types.TextValue(version)),
table.ValueParam("$createAtUnixNano", types.Int64Value(truetime.UnixNano())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ func init() {
err := YDBMigrations.Register("initial", "", func(ctx context.Context, client TableClientWithOptions) error {
return client.client.Do(ctx, func(ctx context.Context, s table.Session) error {
statements := []string{
common.RewriteQuery(createSchemaVersion, client.opts.tablePathPrefix),
common.RewriteQuery(createUniqueIDTable, client.opts.tablePathPrefix),
common.RewriteQuery(createNamespaceConfig, client.opts.tablePathPrefix),
common.RewriteQuery(createCaveat, client.opts.tablePathPrefix),
common.RewriteQuery(createRelationTuple, client.opts.tablePathPrefix),
common.AddTablePrefix(createSchemaVersion, client.opts.tablePathPrefix),
common.AddTablePrefix(createUniqueIDTable, client.opts.tablePathPrefix),
common.AddTablePrefix(createNamespaceConfig, client.opts.tablePathPrefix),
common.AddTablePrefix(createCaveat, client.opts.tablePathPrefix),
common.AddTablePrefix(createRelationTuple, client.opts.tablePathPrefix),
}
for _, stmt := range statements {
if err := s.ExecuteSchemeQuery(ctx, stmt); err != nil {
Expand All @@ -100,7 +100,7 @@ func init() {
}, func(ctx context.Context, tx TxActorWithOptions) error {
_, err := tx.tx.Execute(
ctx,
common.RewriteQuery(insertUniqueID, tx.opts.tablePathPrefix),
common.AddTablePrefix(insertUniqueID, tx.opts.tablePathPrefix),
&table.QueryParameters{},
)
return err
Expand Down

0 comments on commit 63287c8

Please sign in to comment.