Skip to content

Commit a5cbc6d

Browse files
committed
Fix(sql) replace all select * with specific fields.
Signed-off-by: WhereAreBugs <[email protected]>
1 parent a703f1e commit a5cbc6d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

internal/storage/sql.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var (
6363
SetVersion = `UPDATE version SET version = ?, lastconfirm = ? WHERE id = ?`
6464

6565
// select version
66-
SelectVersion = `SELECT * FROM version`
66+
SelectVersion = `SELECT id, version, lastconfirm FROM version`
6767
)
6868

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

9292
// select hosts
93-
SelectHosts = `SELECT * FROM hosts`
93+
SelectHosts = `SELECT id,data,lastmodified_time FROM hosts`
9494
)
9595

9696
// cluster
@@ -137,10 +137,10 @@ var (
137137
DeleteCluster = `DELETE from clusters WHERE name = ?`
138138

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

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

145145
// checkout cluster
146146
CheckoutCluster = `
@@ -180,10 +180,10 @@ var (
180180
InsertService = `INSERT INTO containers(id, cluster_id, container_id) VALUES(?, ?, ?)`
181181

182182
// select service
183-
SelectService = `SELECT * FROM containers WHERE id = ?`
183+
SelectService = `SELECT id,cluster_id,container_id FROM containers WHERE id = ?`
184184

185185
// select services in cluster
186-
SelectServicesInCluster = `SELECT * FROM containers WHERE cluster_id = ?`
186+
SelectServicesInCluster = `SELECT id, cluster_id, container_id FROM containers WHERE cluster_id = ?`
187187

188188
// set service container id
189189
SetContainerId = `UPDATE containers SET container_id = ? WHERE id = ?`
@@ -216,10 +216,10 @@ var (
216216
SetClientAuxInfo = `UPDATE clients SET aux_info = ? WHERE id = ?`
217217

218218
// select clients
219-
SelectClients = `SELECT * FROM clients`
219+
SelectClients = `SELECT id, kind, host, container_id, aux_info FROM clients`
220220

221221
// select client by id
222-
SelectClientById = `SELECT * FROM clients WHERE id = ?`
222+
SelectClientById = `SELECT id, kind, host, container_id, aux_info FROM clients WHERE id = ?`
223223

224224
// delete client
225225
DeleteClient = `DELETE from clients WHERE id = ?`
@@ -256,10 +256,10 @@ var (
256256
SetPlaygroundStatus = `UPDATE playgrounds SET status = ? WHERE name = ?`
257257

258258
// select playground
259-
SelectPlayground = `SELECT * FROM playgrounds WHERE name LIKE ?`
259+
SelectPlayground = `SELECT id, name, create_time, mount_point, status FROM playgrounds WHERE name LIKE ?`
260260

261261
// select playground by id
262-
SelectPlaygroundById = `SELECT * FROM playgrounds WHERE id = ?`
262+
SelectPlaygroundById = `SELECT id, name, create_time, mount_point, status FROM playgrounds WHERE id = ?`
263263

264264
// delete playground
265265
DeletePlayground = `DELETE from playgrounds WHERE name = ?`
@@ -298,10 +298,10 @@ var (
298298
SetAuditLogStatus = `UPDATE audit SET status = ?, error_code = ? WHERE id = ?`
299299

300300
// select audit log
301-
SelectAuditLog = `SELECT * FROM audit`
301+
SelectAuditLog = `SELECT id, execute_time, work_directory, command, status, error_code FROM audit`
302302

303303
// select audit log by id
304-
SelectAuditLogById = `SELECT * FROM audit WHERE id = ?`
304+
SelectAuditLogById = `SELECT id, execute_time, work_directory, command, status, error_code FROM audit WHERE id = ?`
305305
)
306306

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

328328
// select item by id
329-
SelectAnyItem = `SELECT * FROM any WHERE id = ?`
329+
SelectAnyItem = `SELECT id, data FROM any WHERE id = ?`
330330

331331
// delete item
332332
DeleteAnyItem = `DELETE from any WHERE id = ?`

0 commit comments

Comments
 (0)