sql: capitalize keywords

Capitalize some keywords which were overlooked

Change-Id: Ie2ad283669e2ca2650fcddfd8c7395a81bac09a8
This commit is contained in:
Erik van Velzen 2022-02-22 15:41:20 +01:00 committed by Michał Niewrzał
parent ba6956db0f
commit a9bd983f04
12 changed files with 28 additions and 28 deletions

View File

@ -107,7 +107,7 @@ func generateStripeCustomers(ctx context.Context) (err error) {
cusDB := db.StripeCoinPayments().Customers().Raw()
rows, err := cusDB.Query(ctx, "SELECT id, email, signup_promo_code FROM users WHERE id NOT IN (SELECT user_id from stripe_customers) AND users.status=1")
rows, err := cusDB.Query(ctx, "SELECT id, email, signup_promo_code FROM users WHERE id NOT IN (SELECT user_id FROM stripe_customers) AND users.status=1")
if err != nil {
return err
}

View File

@ -110,7 +110,7 @@ func (db *DB) DeleteObjectExactVersion(ctx context.Context, opts DeleteObjectExa
encryption
), deleted_segments AS (
DELETE FROM segments
WHERE segments.stream_id in (SELECT deleted_objects.stream_id FROM deleted_objects)
WHERE segments.stream_id IN (SELECT deleted_objects.stream_id FROM deleted_objects)
RETURNING segments.stream_id,segments.root_piece_id, segments.remote_alias_pieces
)
SELECT
@ -181,7 +181,7 @@ func (db *DB) DeletePendingObject(ctx context.Context, opts DeletePendingObject)
encryption
), deleted_segments AS (
DELETE FROM segments
WHERE segments.stream_id in (SELECT deleted_objects.stream_id FROM deleted_objects)
WHERE segments.stream_id IN (SELECT deleted_objects.stream_id FROM deleted_objects)
RETURNING segments.stream_id,segments.root_piece_id, segments.remote_alias_pieces
)
SELECT
@ -237,7 +237,7 @@ func (db *DB) DeleteObjectAnyStatusAllVersions(ctx context.Context, opts DeleteO
encryption
), deleted_segments AS (
DELETE FROM segments
WHERE segments.stream_id in (SELECT deleted_objects.stream_id FROM deleted_objects)
WHERE segments.stream_id IN (SELECT deleted_objects.stream_id FROM deleted_objects)
RETURNING segments.stream_id,segments.root_piece_id, segments.remote_alias_pieces
)
SELECT
@ -314,7 +314,7 @@ func (db *DB) DeleteObjectsAllVersions(ctx context.Context, opts DeleteObjectsAl
encryption
), deleted_segments AS (
DELETE FROM segments
WHERE segments.stream_id in (SELECT deleted_objects.stream_id FROM deleted_objects)
WHERE segments.stream_id IN (SELECT deleted_objects.stream_id FROM deleted_objects)
RETURNING segments.stream_id,segments.root_piece_id, segments.remote_alias_pieces
)
SELECT

View File

@ -50,7 +50,7 @@ func (db *DB) DeleteBucketObjects(ctx context.Context, opts DeleteBucketObjects)
RETURNING objects.stream_id
)
DELETE FROM segments
WHERE segments.stream_id in (SELECT deleted_objects.stream_id FROM deleted_objects)
WHERE segments.stream_id IN (SELECT deleted_objects.stream_id FROM deleted_objects)
RETURNING segments.stream_id, segments.root_piece_id, segments.remote_alias_pieces
`
case dbutil.Postgres:
@ -65,7 +65,7 @@ func (db *DB) DeleteBucketObjects(ctx context.Context, opts DeleteBucketObjects)
RETURNING objects.stream_id
)
DELETE FROM segments
WHERE segments.stream_id in (SELECT deleted_objects.stream_id FROM deleted_objects)
WHERE segments.stream_id IN (SELECT deleted_objects.stream_id FROM deleted_objects)
RETURNING segments.stream_id, segments.root_piece_id, segments.remote_alias_pieces
`
default:

View File

@ -352,7 +352,7 @@ func (db *gracefulexitDB) GetFinishedExitNodes(ctx context.Context, before time.
// affect correctness.
func (db *gracefulexitDB) DeleteBatchExitProgress(ctx context.Context, nodeIDs []storj.NodeID) (deleted int64, err error) {
defer mon.Task()(&ctx)(&err)
stmt := `DELETE from graceful_exit_progress
stmt := `DELETE FROM graceful_exit_progress
WHERE node_id = ANY($1)`
for len(nodeIDs) > 0 {
numToSubmit := len(nodeIDs)
@ -468,8 +468,8 @@ func (db *gracefulexitDB) GetIncompleteFailed(ctx context.Context, nodeID storj.
order_limit_send_count
FROM graceful_exit_segment_transfer_queue
WHERE node_id = ?
AND finished_at is NULL
AND last_failed_at is not NULL
AND finished_at IS NULL
AND last_failed_at IS NOT NULL
AND failed_count < ?
ORDER BY durability_ratio asc, queued_at asc LIMIT ? OFFSET ?`
rows, err := db.db.Query(ctx, db.db.Rebind(sql), nodeID.Bytes(), maxFailures, limit, offset)

View File

@ -767,8 +767,8 @@ func (db *satelliteDB) PostgresMigration() *migrate.Migration {
) >= 10
OR comp_at_rest < 0
)
AND codes not like '%O%'
AND codes not like '%D%'
AND codes NOT LIKE '%O%'
AND codes NOT LIKE '%D%'
AND period < '2020-03'
`},
},
@ -918,7 +918,7 @@ func (db *satelliteDB) PostgresMigration() *migrate.Migration {
Description: "enable multiple projects for existing users",
Version: 127,
Action: migrate.SQL{
`UPDATE users SET project_limit=0 WHERE project_limit <= 10 and project_limit > 0;`,
`UPDATE users SET project_limit=0 WHERE project_limit <= 10 AND project_limit > 0;`,
},
},
{

View File

@ -206,14 +206,14 @@ func nodeSelectionCondition(ctx context.Context, criteria *overlay.NodeCriteria,
if len(excludedIDs) > 0 {
conds.add(
`not (id = any(?::bytea[]))`,
`NOT (id = ANY(?::bytea[]))`,
pgutil.NodeIDArray(excludedIDs),
)
}
if criteria.DistinctIP {
if len(excludedNetworks) > 0 {
conds.add(
`not (last_net = any(?::text[]))`,
`NOT (last_net = ANY(?::text[]))`,
pgutil.TextArray(excludedNetworks),
)
}

View File

@ -38,7 +38,7 @@ func (db *revocationDB) Check(ctx context.Context, tails [][]byte) (bool, error)
finalTail := tails[numTails-1]
val, err := db.lru.Get(string(finalTail), func() (interface{}, error) {
const query = "select exists(select 1 from revocations where revoked in (%s))"
const query = "SELECT EXISTS(SELECT 1 FROM revocations WHERE revoked IN (%s))"
var (
tailQuery, comma string

View File

@ -100,7 +100,7 @@ func (db *StoragenodeAccounting) GetTalliesSince(ctx context.Context, latestRoll
func (db *StoragenodeAccounting) getNodeIdsSince(ctx context.Context, since time.Time) (nodeids [][]byte, err error) {
defer mon.Task()(&ctx)(&err)
rows, err := db.db.QueryContext(ctx, db.db.Rebind(`select distinct storagenode_id from storagenode_bandwidth_rollups where interval_start >= $1`), since)
rows, err := db.db.QueryContext(ctx, db.db.Rebind(`SELECT DISTINCT storagenode_id FROM storagenode_bandwidth_rollups WHERE interval_start >= $1`), since)
if err != nil {
return nil, Error.Wrap(err)
}

View File

@ -136,7 +136,7 @@ func (db *bandwidthDB) getSummary(ctx context.Context, from, to time.Time, filte
from, to = from.UTC(), to.UTC()
rows, err := db.QueryContext(ctx, `
SELECT action, sum(a) amount from(
SELECT action, sum(a) amount FROM(
SELECT action, sum(amount) a
FROM bandwidth_usage
WHERE datetime(?) <= created_at AND created_at <= datetime(?)
@ -198,7 +198,7 @@ func (db *bandwidthDB) getSatelliteSummary(ctx context.Context, satelliteID stor
from, to = from.UTC(), to.UTC()
query := `SELECT action, sum(a) amount from(
query := `SELECT action, sum(a) amount FROM(
SELECT action, sum(amount) a
FROM bandwidth_usage
WHERE datetime(?) <= created_at AND created_at <= datetime(?)
@ -245,7 +245,7 @@ func (db *bandwidthDB) SummaryBySatellite(ctx context.Context, from, to time.Tim
from, to = from.UTC(), to.UTC()
rows, err := db.QueryContext(ctx, `
SELECT satellite_id, action, sum(a) amount from(
SELECT satellite_id, action, sum(a) amount FROM(
SELECT satellite_id, action, sum(amount) a
FROM bandwidth_usage
WHERE datetime(?) <= created_at AND created_at <= datetime(?)

View File

@ -955,7 +955,7 @@ func (db *DB) Migration(ctx context.Context) *migrate.Migration {
satellite_id BLOB
)`,
`CREATE UNIQUE INDEX idx_piece_space_used_satellite_id ON piece_space_used(satellite_id)`,
`INSERT INTO piece_space_used (total) select ifnull(sum(piece_size), 0) from pieceinfo_`,
`INSERT INTO piece_space_used (total) SELECT IFNULL(SUM(piece_size), 0) FROM pieceinfo_`,
},
},
{

View File

@ -264,7 +264,7 @@ func (db *payoutDB) SatellitesHeldbackHistory(ctx context.Context, id storj.Node
func (db *payoutDB) SatellitePeriods(ctx context.Context, satelliteID storj.NodeID) (_ []string, err error) {
defer mon.Task()(&ctx)(&err)
query := `SELECT distinct period FROM paystubs WHERE satellite_id = ? ORDER BY created_at`
query := `SELECT DISTINCT period FROM paystubs WHERE satellite_id = ? ORDER BY created_at`
rows, err := db.QueryContext(ctx, query, satelliteID[:])
if err != nil {
@ -294,7 +294,7 @@ func (db *payoutDB) SatellitePeriods(ctx context.Context, satelliteID storj.Node
func (db *payoutDB) AllPeriods(ctx context.Context) (_ []string, err error) {
defer mon.Task()(&ctx)(&err)
query := `SELECT distinct period FROM paystubs ORDER BY created_at`
query := `SELECT DISTINCT period FROM paystubs ORDER BY created_at`
rows, err := db.QueryContext(ctx, query)
if err != nil {
@ -593,7 +593,7 @@ func (db *payoutDB) GetSatellitePaystubs(ctx context.Context, satelliteID storj.
rowPayment := db.QueryRowContext(ctx,
`SELECT COALESCE(SUM(usage_at_rest),0), COALESCE(SUM(usage_get),0), COALESCE(SUM(usage_get_repair),0), COALESCE(SUM(usage_get_audit),0),
COALESCE(SUM(comp_at_rest),0), COALESCE(SUM(comp_get),0), COALESCE(SUM(comp_get_repair),0), COALESCE(SUM(comp_get_audit),0),
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) from paystubs WHERE satellite_id = $1`, satelliteID)
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) FROM paystubs WHERE satellite_id = $1`, satelliteID)
var paystub payouts.PayStub
@ -625,7 +625,7 @@ func (db *payoutDB) GetPaystubs(ctx context.Context) (_ *payouts.PayStub, err er
rowPayment := db.QueryRowContext(ctx,
`SELECT COALESCE(SUM(usage_at_rest),0), COALESCE(SUM(usage_get),0), COALESCE(SUM(usage_get_repair),0), COALESCE(SUM(usage_get_audit),0),
COALESCE(SUM(comp_at_rest),0), COALESCE(SUM(comp_get),0), COALESCE(SUM(comp_get_repair),0), COALESCE(SUM(comp_get_audit),0),
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) from paystubs`)
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) FROM paystubs`)
var paystub payouts.PayStub
@ -657,7 +657,7 @@ func (db *payoutDB) GetPeriodPaystubs(ctx context.Context, period string) (_ *pa
rowPayment := db.QueryRowContext(ctx,
`SELECT COALESCE(SUM(usage_at_rest),0), COALESCE(SUM(usage_get),0), COALESCE(SUM(usage_get_repair),0), COALESCE(SUM(usage_get_audit),0),
COALESCE(SUM(comp_at_rest),0), COALESCE(SUM(comp_get),0), COALESCE(SUM(comp_get_repair),0), COALESCE(SUM(comp_get_audit),0),
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) from paystubs WHERE period = $1`, period)
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) FROM paystubs WHERE period = $1`, period)
var paystub payouts.PayStub
@ -689,7 +689,7 @@ func (db *payoutDB) GetSatellitePeriodPaystubs(ctx context.Context, period strin
rowPayment := db.QueryRowContext(ctx,
`SELECT COALESCE(SUM(usage_at_rest),0), COALESCE(SUM(usage_get),0), COALESCE(SUM(usage_get_repair),0), COALESCE(SUM(usage_get_audit),0),
COALESCE(SUM(comp_at_rest),0), COALESCE(SUM(comp_get),0), COALESCE(SUM(comp_get_repair),0), COALESCE(SUM(comp_get_audit),0),
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) from paystubs WHERE period = $1 AND satellite_id = $2`, period, satelliteID)
COALESCE(SUM(held),0), COALESCE(SUM(paid),0), COALESCE(SUM(distributed),0), COALESCE(SUM(disposed),0) FROM paystubs WHERE period = $1 AND satellite_id = $2`, period, satelliteID)
var paystub payouts.PayStub

View File

@ -44,7 +44,7 @@ func (db *satellitesDB) SetAddress(ctx context.Context, satelliteID storj.NodeID
func (db *satellitesDB) GetSatellite(ctx context.Context, satelliteID storj.NodeID) (satellite satellites.Satellite, err error) {
defer mon.Task()(&ctx)(&err)
rows, err := db.QueryContext(ctx, "SELECT node_id, added_at, status from satellites where node_id = ?", satelliteID)
rows, err := db.QueryContext(ctx, "SELECT node_id, added_at, status FROM satellites WHERE node_id = ?", satelliteID)
if err != nil {
return satellite, err
}