Skip to content

Commit

Permalink
sql: capitalize keywords
Browse files Browse the repository at this point in the history
Capitalize some keywords which were overlooked

Change-Id: Ie2ad283669e2ca2650fcddfd8c7395a81bac09a8
  • Loading branch information
Erikvv authored and mniewrzal committed Mar 1, 2022
1 parent ba6956d commit a9bd983
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/satellite/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions satellite/metabase/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions satellite/metabase/delete_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions satellite/satellitedb/gracefulexit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions satellite/satellitedb/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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'
`},
},
Expand Down Expand Up @@ -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;`,
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions satellite/satellitedb/nodeselection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}
Expand Down
2 changes: 1 addition & 1 deletion satellite/satellitedb/revocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion satellite/satellitedb/storagenodeaccounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions storagenode/storagenodedb/bandwidthdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(?)
Expand Down Expand Up @@ -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(?)
Expand Down Expand Up @@ -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(?)
Expand Down
2 changes: 1 addition & 1 deletion storagenode/storagenodedb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_`,
},
},
{
Expand Down
12 changes: 6 additions & 6 deletions storagenode/storagenodedb/payouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion storagenode/storagenodedb/satellites.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit a9bd983

Please sign in to comment.