Skip to content
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

Fix(sql) replace all select * with specific fields. #390

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions internal/storage/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var (
SetVersion = `UPDATE version SET version = ?, lastconfirm = ? WHERE id = ?`

// select version
SelectVersion = `SELECT * FROM version`
SelectVersion = `SELECT id, version, lastconfirm FROM version`
)

// hosts
Expand All @@ -90,7 +90,7 @@ var (
SetHosts = `UPDATE hosts SET data = ?, lastmodified_time = datetime('now','localtime') WHERE id = ?`

// select hosts
SelectHosts = `SELECT * FROM hosts`
SelectHosts = `SELECT id, data, lastmodified_time FROM hosts`
)

// cluster
Expand Down Expand Up @@ -137,10 +137,10 @@ var (
DeleteCluster = `DELETE from clusters WHERE name = ?`

// select cluster
SelectCluster = `SELECT * FROM clusters WHERE name LIKE ?`
SelectCluster = `SELECT id, uuid, name, description, topology, pool, create_time, current, type FROM clusters WHERE name LIKE ?`

// get current cluster
GetCurrentCluster = `SELECT * FROM clusters WHERE current = 1`
GetCurrentCluster = `SELECT id, uuid, name, description, topology, pool, create_time, current, type FROM clusters WHERE current = 1`

// checkout cluster
CheckoutCluster = `
Expand Down Expand Up @@ -180,10 +180,10 @@ var (
InsertService = `INSERT INTO containers(id, cluster_id, container_id) VALUES(?, ?, ?)`

// select service
SelectService = `SELECT * FROM containers WHERE id = ?`
SelectService = `SELECT id, cluster_id, container_id FROM containers WHERE id = ?`

// select services in cluster
SelectServicesInCluster = `SELECT * FROM containers WHERE cluster_id = ?`
SelectServicesInCluster = `SELECT id, cluster_id, container_id FROM containers WHERE cluster_id = ?`

// set service container id
SetContainerId = `UPDATE containers SET container_id = ? WHERE id = ?`
Expand Down Expand Up @@ -216,10 +216,10 @@ var (
SetClientAuxInfo = `UPDATE clients SET aux_info = ? WHERE id = ?`

// select clients
SelectClients = `SELECT * FROM clients`
SelectClients = `SELECT id, kind, host, container_id, aux_info FROM clients`

// select client by id
SelectClientById = `SELECT * FROM clients WHERE id = ?`
SelectClientById = `SELECT id, kind, host, container_id, aux_info FROM clients WHERE id = ?`

// delete client
DeleteClient = `DELETE from clients WHERE id = ?`
Expand Down Expand Up @@ -256,10 +256,10 @@ var (
SetPlaygroundStatus = `UPDATE playgrounds SET status = ? WHERE name = ?`

// select playground
SelectPlayground = `SELECT * FROM playgrounds WHERE name LIKE ?`
SelectPlayground = `SELECT id, name, create_time, mount_point, status FROM playgrounds WHERE name LIKE ?`

// select playground by id
SelectPlaygroundById = `SELECT * FROM playgrounds WHERE id = ?`
SelectPlaygroundById = `SELECT id, name, create_time, mount_point, status FROM playgrounds WHERE id = ?`

// delete playground
DeletePlayground = `DELETE from playgrounds WHERE name = ?`
Expand Down Expand Up @@ -298,10 +298,10 @@ var (
SetAuditLogStatus = `UPDATE audit SET status = ?, error_code = ? WHERE id = ?`

// select audit log
SelectAuditLog = `SELECT * FROM audit`
SelectAuditLog = `SELECT id, execute_time, work_directory, command, status, error_code FROM audit`

// select audit log by id
SelectAuditLogById = `SELECT * FROM audit WHERE id = ?`
SelectAuditLogById = `SELECT id, execute_time, work_directory, command, status, error_code FROM audit WHERE id = ?`
)

// any: we can store anything
Expand All @@ -326,7 +326,7 @@ var (
SetAnyItem = `UPDATE any SET data = ? WHERE id = ?`

// select item by id
SelectAnyItem = `SELECT * FROM any WHERE id = ?`
SelectAnyItem = `SELECT id, data FROM any WHERE id = ?`

// delete item
DeleteAnyItem = `DELETE from any WHERE id = ?`
Expand Down