Skip to content

Commit 7c88ca5

Browse files
committed
use db.QueryRow
1 parent be3c0aa commit 7c88ca5

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

examples/user_demo/user_demo.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func main() {
145145

146146
db.SetConn(conn)
147147

148-
err = db.Conn(ctx).Exec("...")
148+
err = db.Exec(ctx, "...")
149149
if err != nil {
150150
panic(err)
151151
}
@@ -158,17 +158,17 @@ func main() {
158158
return err
159159
}
160160
if user == nil {
161-
return db.Conn(ctx).Exec("...")
161+
return db.Exec(ctx, "...")
162162
}
163-
return db.Conn(ctx).Exec("...")
163+
return db.Exec(ctx, "...")
164164
})
165165
if err != nil {
166166
panic(err)
167167
}
168168
}
169169

170170
func GetUserOrNil(ctx context.Context, userID uu.ID) (user *User, err error) {
171-
err = db.Conn(ctx).QueryRow(
171+
err = db.QueryRow(ctx,
172172
`select * from public.user where id = $1`,
173173
userID,
174174
).ScanStruct(&user)

information/column.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func ColumnExists(ctx context.Context, table, column string) (exists bool, err e
7676
tableName = table
7777
}
7878

79-
err = db.Conn(ctx).QueryRow(
79+
err = db.QueryRow(ctx,
8080
`select exists(
8181
select from information_schema.columns
8282
where table_schema = $1

information/primarykeys.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type PrimaryKeyColumn struct {
2727
func GetPrimaryKeyColumns(ctx context.Context) (cols []PrimaryKeyColumn, err error) {
2828
defer errs.WrapWithFuncParams(&err, ctx)
2929

30-
err = db.Conn(ctx).QueryRows(`
30+
err = db.QueryRows(ctx, `
3131
select
3232
tc.table_schema||'.'||tc.table_name as "table",
3333
kc.column_name as "column",
@@ -67,7 +67,7 @@ func GetPrimaryKeyColumns(ctx context.Context) (cols []PrimaryKeyColumn, err err
6767
func GetPrimaryKeyColumnsOfType(ctx context.Context, pkType string) (cols []PrimaryKeyColumn, err error) {
6868
defer errs.WrapWithFuncParams(&err, ctx, pkType)
6969

70-
err = db.Conn(ctx).QueryRows(`
70+
err = db.QueryRows(ctx, `
7171
select
7272
tc.table_schema||'.'||tc.table_name as "table",
7373
kc.column_name as "column",

information/table.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Table struct {
2222
}
2323

2424
func GetTable(ctx context.Context, catalog, schema, name string) (table *Table, err error) {
25-
err = db.Conn(ctx).QueryRow(
25+
err = db.QueryRow(ctx,
2626
`select *
2727
from information_schema.tables
2828
where table_catalog = $1
@@ -39,7 +39,7 @@ func GetTable(ctx context.Context, catalog, schema, name string) (table *Table,
3939
}
4040

4141
func GetAllTables(ctx context.Context) (tables []*Table, err error) {
42-
err = db.Conn(ctx).QueryRows(
42+
err = db.QueryRows(ctx,
4343
`select * from information_schema.tables`,
4444
).ScanStructSlice(&tables)
4545
if err != nil {

0 commit comments

Comments
 (0)