mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
add insert,tryInsert unify for postgres that need pk name (#14416)
* add insert,tryInsert unify for postgres that need pk name * add ReadDbEffect to new procs * add .since and changelog * change since to 1.3 * Update src/db_postgres.nim Co-authored-by: bung87 <crc32@qq.com> Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: alaviss <leorize+oss@disroot.org>
This commit is contained in:
@@ -118,6 +118,8 @@ import sqlite3
|
||||
import db_common
|
||||
export db_common
|
||||
|
||||
import std/private/since
|
||||
|
||||
type
|
||||
DbConn* = PSqlite3 ## Encapsulates a database connection.
|
||||
Row* = seq[string] ## A row of a dataset. `NULL` database values will be
|
||||
@@ -636,6 +638,19 @@ proc insertID*(db: DbConn, query: SqlQuery,
|
||||
result = tryInsertID(db, query, args)
|
||||
if result < 0: dbError(db)
|
||||
|
||||
proc tryInsert*(db: DbConn, query: SqlQuery, pkName: string,
|
||||
args: varargs[string, `$`]): int64
|
||||
{.tags: [WriteDbEffect], raises: [], since: (1, 3).} =
|
||||
## same as tryInsertID
|
||||
tryInsertID(db, query, args)
|
||||
|
||||
proc insert*(db: DbConn, query: SqlQuery, pkName: string,
|
||||
args: varargs[string, `$`]): int64
|
||||
{.tags: [WriteDbEffect], since: (1, 3).} =
|
||||
## same as insertId
|
||||
result = tryInsert(db, query,pkName, args)
|
||||
if result < 0: dbError(db)
|
||||
|
||||
proc execAffectedRows*(db: DbConn, query: SqlQuery,
|
||||
args: varargs[string, `$`]): int64 {.
|
||||
tags: [ReadDbEffect, WriteDbEffect].} =
|
||||
|
||||
Reference in New Issue
Block a user