build the documentation of official packages (#20986)

* remove db stuffs

* remove punycode

* remove

* fixes script

* add cloner

* patches

* disable

* patch

* fixes external packages

* disable two packages

* preview documentation build

* try again

* fixes URL

* fixes a bug

* simplify

* fixes documentaion

* fixes

* Apply suggestions from code review
This commit is contained in:
ringabout 2022-12-06 22:37:16 +08:00 • committed by GitHub
commit 9ba07edb2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 92 additions and 6358 deletions

View file

@ -39,11 +39,6 @@ import
cpuload,
critbits,
cstrutils,
db_common,
db_mysql,
db_odbc,
db_postgres,
db_sqlite,
deques,
distros,
dynlib,
@ -95,7 +90,6 @@ import
pegs,
posix_utils,
prelude,
punycode,
random,
rationals,
rdstdin,

View file

@ -25,7 +25,7 @@ import std/[
# Strings:
cstrutils, editdistance, wordwrap, parseutils, ropes,
pegs, punycode, strformat, strmisc, strscans, strtabs,
pegs, strformat, strmisc, strscans, strtabs,
strutils, unicode, unidecode,
# fails due to FFI: encodings

View file

@ -1,4 +1,5 @@
discard """
disabled: true
output: "Database created successfully!"
"""

View file

@ -1,4 +1,5 @@
discard """
disabled: true
action: compile
matrix: "--threads:off"
"""

View file

@ -1,4 +1,5 @@
discard """
disabled: true
outputsub: "All tests finished successfully!"
"""

View file

@ -1,25 +0,0 @@
discard """
action: "compile"
"""
import db_mysql, db_odbc, db_postgres
import os
from stdtest/specialpaths import buildDir
block:
block:
const dbName = buildDir / "db.sqlite3"
var db = db_mysql.open(dbName, "", "", "")
discard tryInsertId(db, sql"INSERT INTO myTestTbl (name,i,f) VALUES (?,?,?)", "t")
block:
const dbName = buildDir / "db.odbc"
var db = db_odbc.open(dbName, "", "", "")
discard tryInsertId(db, sql"INSERT INTO myTestTbl (name,i,f) VALUES (?,?,?)", "t")
block:
const dbName = buildDir / "db.postgres"
var db = db_postgres.open(dbName, "", "", "")
discard tryInsertId(db, sql"INSERT INTO myTestTbl (name,i,f) VALUES (?,?,?)", "t")

View file

@ -1,5 +0,0 @@
import std/db_mysql
import std/assertions
doAssert dbQuote("SELECT * FROM foo WHERE col1 = 'bar_baz'") == "'SELECT * FROM foo WHERE col1 = \\'bar_baz\\''"
doAssert dbQuote("SELECT * FROM foo WHERE col1 LIKE '%bar_baz%'") == "'SELECT * FROM foo WHERE col1 LIKE \\'%bar_baz%\\''"

View file

@ -1,206 +0,0 @@
import punycode, std/unicode
import std/assertions
doAssert(decode(encode("", "bücher")) == "bücher")
doAssert(decode(encode("münchen")) == "münchen")
doAssert encode("xn--", "münchen") == "xn--mnchen-3ya"
# source: https://datatracker.ietf.org/doc/html/rfc3492.html#section-7
let punycode_testcases = [
# (A) Arabic (Egyptian):
(
input:
"\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" &
"\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F",
output:
"egbpdaj6bu4bxfgehfvwxn"
),
# (B) Chinese (simplified):
(
input:
"\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587",
output:
"ihqwcrb4cv8a8dqg056pqjye"
),
# (C) Chinese (traditional):
(
input:
"\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587",
output:
"ihqwctvzc91f659drss3x8bo0yb"
),
# (D) Czech: Pro<ccaron>prost<ecaron>nemluv<iacute><ccaron>esky
(
input:
"\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074" &
"\u011B\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D" &
"\u0065\u0073\u006B\u0079",
output:
"Proprostnemluvesky-uyb24dma41a"
),
# (E) Hebrew:
(
input:
"\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8" &
"\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2" &
"\u05D1\u05E8\u05D9\u05EA",
output:
"4dbcagdahymbxekheh6e0a7fei0b"
),
# (F) Hindi (Devanagari):
(
input:
"\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D" &
"\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939" &
"\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947" &
"\u0939\u0948\u0902",
output:
"i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd"
),
# (G) Japanese (kanji and hiragana):
(
input:
"\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092" &
"\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B",
output:
"n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa"
),
# (H) Korean (Hangul syllables):
(
input:
"\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774" &
"\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74" &
"\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C",
output:
"989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c"
),
# (I) Russian (Cyrillic):
(
input:
"\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E" &
"\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440" &
"\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A" &
"\u0438",
output:
"b1abfaaepdrnnbgefbaDotcwatmq2g4l"
),
# (J) Spanish: Porqu<eacute>nopuedensimplementehablarenEspa<ntilde>ol
(
input:
"\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070" &
"\u0075\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070" &
"\u006C\u0065\u006D\u0065\u006E\u0074\u0065\u0068\u0061" &
"\u0062\u006C\u0061\u0072\u0065\u006E\u0045\u0073\u0070" &
"\u0061\u00F1\u006F\u006C",
output:
"PorqunopuedensimplementehablarenEspaol-fmd56a"
),
# (K) Vietnamese:
# T<adotbelow>isaoh<odotbelow>kh<ocirc>ngth<ecirchookabove>ch\
# <ihookabove>n<oacute>iti<ecircacute>ngVi<ecircdotbelow>t
(
input:
"\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B" &
"\u0068\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068" &
"\u1EC9\u006E\u00F3\u0069\u0074\u0069\u1EBF\u006E\u0067" &
"\u0056\u0069\u1EC7\u0074",
output:
"TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g"
),
# (L) 3<nen>B<gumi><kinpachi><sensei>
(
input:
"\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F",
output:
"3B-ww4c5e180e575a65lsy2b"
),
# (M) <amuro><namie>-with-SUPER-MONKEYS
(
input:
"\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074" &
"\u0068\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D" &
"\u004F\u004E\u004B\u0045\u0059\u0053",
output:
"-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n"
),
# (N) Hello-Another-Way-<sorezore><no><basho>
(
input:
"\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F" &
"\u0074\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D" &
"\u305D\u308C\u305E\u308C\u306E\u5834\u6240",
output:
"Hello-Another-Way--fc4qua05auwb3674vfr0b"
),
# (O) <hitotsu><yane><no><shita>2
(
input:
"\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032",
output:
"2-u9tlzr9756bt3uc0v"
),
# (P) Maji<de>Koi<suru>5<byou><mae>
(
input:
"\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" &
"\u308B\u0035\u79D2\u524D",
output:
"MajiKoi5-783gue6qz075azm5e"
),
# (Q) <pafii>de<runba>
(
input:
"\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0",
output:
"de-jg4avhby1noc0d"
),
# (R) <sono><supiido><de>
(
input:
"\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067",
output:
"d9juau41awczczp"
),
# (S) -> $1.00 <-
(
input:
"\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020" &
"\u003C\u002D",
output:
"-> $1.00 <--"
)
]
block encodeTests:
for (uni, puny) in punycode_testcases:
# Need to convert both strings to lower case, since
# some of the extended encodings use upper case, but our
# code produces only lower case. Converting just puny to
# lower is also insufficient, since some of the input characters
# are upper case.
doAssert encode(uni).toLower() == puny.toLower()
block decodeTests:
for (uni, puny) in punycode_testcases:
doAssert decode(puny) == uni
block decodeInvalidTest:
doAssertRaises(PunyError): discard decode("xn--w&")

View file

@ -1,79 +0,0 @@
discard """
action: "run"
exitcode: 0
"""
import db_sqlite
import random
import os
from stdtest/specialpaths import buildDir
import std/assertions
block tsqlitebindatas: ## db_sqlite binary data
const dbName = buildDir / "tsqlitebindatas.db"
let origName = "Bobby"
var orig = newSeq[float64](150)
randomize()
for x in orig.mitems:
x = rand(1.0)/10.0
discard tryRemoveFile(dbName)
let db = open(dbName, "", "", "")
let createTableStr = sql"""CREATE TABLE test(
id INTEGER NOT NULL PRIMARY KEY,
name TEXT,
data BLOB
)
"""
db.exec(createTableStr)
var dbuf = newSeq[byte](orig.len*sizeof(float64))
copyMem(addr(dbuf[0]), addr(orig[0]), dbuf.len)
var insertStmt = db.prepare("INSERT INTO test (id, name, data) VALUES (?, ?, ?)")
insertStmt.bindParams(1, origName, dbuf)
let bres = db.tryExec(insertStmt)
doAssert(bres)
finalize(insertStmt)
var nameTest = db.getValue(sql"SELECT name FROM test WHERE id = ?", 1)
doAssert nameTest == origName
var dataTest = db.getValue(sql"SELECT data FROM test WHERE id = ?", 1)
let seqSize = int(dataTest.len*sizeof(byte)/sizeof(float64))
var res: seq[float64] = newSeq[float64](seqSize)
copyMem(addr(res[0]), addr(dataTest[0]), dataTest.len)
doAssert res.len == orig.len
doAssert res == orig
db.close()
doAssert tryRemoveFile(dbName)
block:
block:
const dbName = buildDir / "db.sqlite3"
var db = db_sqlite.open(dbName, "", "", "")
var witness = false
try:
db.exec(sql("CREATE TABLE table1 (url TEXT, other_field INT);"))
db.exec(sql("REPLACE INTO table (url, another_field) VALUES (?, '123');"))
except DbError as e:
witness = true
doAssert e.msg == "The number of \"?\" given exceeds the number of parameters present in the query."
finally:
db.close()
removeFile(dbName)
doAssert witness
block:
const dbName = buildDir / "db.sqlite3"
var db = db_sqlite.open(dbName, "", "", "")
try:
db.exec(sql("CREATE TABLE table1 (url TEXT, other_field INT);"))
db.exec(sql("INSERT INTO table1 (url, other_field) VALUES (?, ?);"), "http://domain.com/test?param=1", 123)
finally:
db.close()
removeFile(dbName)

View file

@ -17,7 +17,7 @@ import std/[
# Strings:
editdistance, wordwrap, parseutils, ropes,
pegs, punycode, strformat, strmisc, strscans, strtabs,
pegs, strformat, strmisc, strscans, strtabs,
strutils, unicode, unidecode,
# Generic operator system services:

View file

@ -17,7 +17,7 @@ import std/[
# Strings:
editdistance, wordwrap, parseutils, ropes,
pegs, punycode, strformat, strmisc, strscans, strtabs,
pegs, strformat, strmisc, strscans, strtabs,
strutils, unicode, unidecode,
# Generic operator system services:

View file

@ -26,7 +26,7 @@ import std/[
# Strings:
editdistance, wordwrap, parseutils, ropes,
pegs, punycode, strformat, strmisc, strscans, strtabs,
pegs, strformat, strmisc, strscans, strtabs,
strutils, unicode, unidecode, cstrutils,
# works but uses FFI: encodings

View file

@ -1,8 +0,0 @@
discard """
action: compile
"""
import db_sqlite
var db: DbConn
exec(db, sql"create table blabla()")

View file

@ -1,332 +1 @@
import db_postgres, strutils
let db = open("localhost", "dom", "", "test")
db.exec(sql"DROP TABLE IF EXISTS myTable")
db.exec(sql("""CREATE TABLE myTable (
id integer PRIMARY KEY,
name varchar(50) not null)"""))
let name = "Dom"
db.exec(sql"INSERT INTO myTable (id, name) VALUES (0, ?)",
name)
doAssert db.getValue(sql"SELECT name FROM myTable") == name
# Check issue #3513
doAssert db.getValue(sql"SELECT name FROM myTable") == name
# issue #3560
proc addToDb(conn: DbConn, fileId: int, fileName: string): int64 =
result = conn.insertId(sql("INSERT into files (id, filename) VALUES (?, ?)"), fileId, fileName)
db.exec(sql"DROP TABLE IF EXISTS files")
db.exec(sql"DROP TABLE IF EXISTS fileobjects")
db.exec(sql("""CREATE TABLE FILEOBJECTS(
ID SERIAL PRIMARY KEY,
FILE_SIZE INT,
MD5 CHAR(32) NOT NULL UNIQUE
);"""))
db.exec(sql("""CREATE TABLE FILES(
ID SERIAL PRIMARY KEY,
OBJECT_ID INT,
FILENAME TEXT NOT NULL,
URI TEXT,
SCHEME CHAR(10),
PUBLIC BOOLEAN DEFAULT FALSE,
CONSTRAINT fk1_fileobjs FOREIGN KEY (object_id)
REFERENCES fileobjects (id) MATCH SIMPLE
ON DELETE CASCADE
);"""))
let f1 = db.addToDb(1, "hello.tmp")
doAssert f1 == 1
let f2 = db.addToDb(2, "hello2.tmp")
doAssert f2 == 2
# PreparedStmt vs. normal query
try:
echo db.getValue(sql("select * from files where id = $1"), 1)
doAssert false, "Exception expected"
except DbError:
let msg = getCurrentExceptionMsg().normalize
info "DbError",
msg = $msg
doAssert "no parameter" in msg
doAssert "$1" in msg
doAssert db.getValue(sql("select filename from files where id = ?"), 1) == "hello.tmp"
var first = prepare(db, "one", sql"select filename from files where id = $1", 1)
doAssert db.getValue(first, 1) == "hello.tmp"
try:
var second = prepare(db, "two", sql"select filename from files where id = ?", 1)
doAssert false, "Exception expected"
except:
let msg = getCurrentExceptionMsg().normalize
doAssert "expects" in msg
doAssert "$1" in msg
doAssert "parameter substitution" in msg
# issue #3569
db.exec(SqlQuery("DROP TABLE IF EXISTS tags"))
db.exec(SqlQuery("CREATE TABLE tags(id serial UNIQUE, name varchar(255))"))
for i in 1..10:
var name = "t" & $i
echo(name)
discard db.getRow(
SqlQuery("INSERT INTO tags(name) VALUES(\'$1\') RETURNING id" % [name]))
# get column details
db.exec(SqlQuery("DROP TABLE IF EXISTS dbtypes;"))
db.exec(SqlQuery("DROP TYPE IF EXISTS custom_enum;"))
db.exec(SqlQuery("CREATE TYPE custom_enum AS ENUM ('1', '2', '3');"))
db.exec(SqlQuery("DROP TYPE IF EXISTS custom_composite;"))
db.exec(SqlQuery("CREATE TYPE custom_composite AS (r double precision, i double precision);"))
db.exec(SqlQuery("""CREATE TABLE dbtypes(
id serial UNIQUE,
bytea_col bytea,
smallint_col smallint,
integer_col integer,
bigint_col bigint,
decimal_col decimal,
numeric_col numeric,
real_col real,
double_precision_col double precision,
smallserial_col smallserial,
serial_col serial,
bigserial_col bigserial,
money_col money,
varchar_col varchar(10),
character_col character(1),
text_col text,
timestamp_col timestamp,
date_col date,
time_col time,
interval_col interval,
bool_col boolean,
custom_enum_col custom_enum,
point_col point,
line_col line,
lseg_col lseg,
box_col box,
path_col path,
polygon_col polygon,
circle_col circle,
cidr_col cidr,
inet_col inet,
macaddr_col macaddr,
bit_col bit,
varbit_col bit(3),
tsvector_col tsvector,
tsquery_col tsquery,
uuid_col uuid,
xml_col xml,
json_col json,
array_col integer[],
custom_composite_col custom_composite,
range_col int4range
);"""))
db.exec(SqlQuery("INSERT INTO dbtypes (id) VALUES(0);"))
var dbCols : DbColumns = @[]
for row in db.instantRows(dbCols, sql"SELECT * FROM dbtypes"):
doAssert len(dbCols) == 42
doAssert dbCols[0].name == "id"
doAssert dbCols[0].typ.kind == DbTypeKind.dbInt
doAssert dbCols[0].typ.name == "int4"
doAssert dbCols[0].typ.size == 4
doAssert dbCols[1].name == "bytea_col"
doAssert dbCols[1].typ.kind == DbTypeKind.dbBlob
doAssert dbCols[1].typ.name == "bytea"
doAssert dbCols[2].name == "smallint_col"
doAssert dbCols[2].typ.kind == DbTypeKind.dbInt
doAssert dbCols[2].typ.name == "int2"
doAssert dbCols[2].typ.size == 2
doAssert dbCols[3].name == "integer_col"
doAssert dbCols[3].typ.kind == DbTypeKind.dbInt
doAssert dbCols[3].typ.name == "int4"
doAssert dbCols[3].typ.size == 4
doAssert dbCols[4].name == "bigint_col"
doAssert dbCols[4].typ.kind == DbTypeKind.dbInt
doAssert dbCols[4].typ.name == "int8"
doAssert dbCols[4].typ.size == 8
doAssert dbCols[5].name == "decimal_col"
doAssert dbCols[5].typ.kind == DbTypeKind.dbDecimal
doAssert dbCols[5].typ.name == "numeric"
doAssert dbCols[6].name == "numeric_col"
doAssert dbCols[6].typ.kind == DbTypeKind.dbDecimal
doAssert dbCols[6].typ.name == "numeric"
doAssert dbCols[7].name == "real_col"
doAssert dbCols[7].typ.kind == DbTypeKind.dbFloat
doAssert dbCols[7].typ.name == "float4"
doAssert dbCols[8].name == "double_precision_col"
doAssert dbCols[8].typ.kind == DbTypeKind.dbFloat
doAssert dbCols[8].typ.name == "float8"
doAssert dbCols[9].name == "smallserial_col"
doAssert dbCols[9].typ.kind == DbTypeKind.dbInt
doAssert dbCols[9].typ.name == "int2"
doAssert dbCols[10].name == "serial_col"
doAssert dbCols[10].typ.kind == DbTypeKind.dbInt
doAssert dbCols[10].typ.name == "int4"
doAssert dbCols[11].name == "bigserial_col"
doAssert dbCols[11].typ.kind == DbTypeKind.dbInt
doAssert dbCols[11].typ.name == "int8"
doAssert dbCols[12].name == "money_col"
doAssert dbCols[12].typ.kind == DbTypeKind.dbDecimal
doAssert dbCols[12].typ.name == "money"
doAssert dbCols[13].name == "varchar_col"
doAssert dbCols[13].typ.kind == DbTypeKind.dbVarchar
doAssert dbCols[13].typ.name == "varchar"
doAssert dbCols[14].name == "character_col"
doAssert dbCols[14].typ.kind == DbTypeKind.dbFixedChar
doAssert dbCols[14].typ.name == "bpchar"
doAssert dbCols[15].name == "text_col"
doAssert dbCols[15].typ.kind == DbTypeKind.dbVarchar
doAssert dbCols[15].typ.name == "text"
doAssert dbCols[16].name == "timestamp_col"
doAssert dbCols[16].typ.kind == DbTypeKind.dbTimestamp
doAssert dbCols[16].typ.name == "timestamp"
doAssert dbCols[17].name == "date_col"
doAssert dbCols[17].typ.kind == DbTypeKind.dbDate
doAssert dbCols[17].typ.name == "date"
doAssert dbCols[18].name == "time_col"
doAssert dbCols[18].typ.kind == DbTypeKind.dbTime
doAssert dbCols[18].typ.name == "time"
doAssert dbCols[19].name == "interval_col"
doAssert dbCols[19].typ.kind == DbTypeKind.dbTimeInterval
doAssert dbCols[19].typ.name == "interval"
doAssert dbCols[20].name == "bool_col"
doAssert dbCols[20].typ.kind == DbTypeKind.dbBool
doAssert dbCols[20].typ.name == "bool"
doAssert dbCols[21].name == "custom_enum_col"
doAssert dbCols[21].typ.kind == DbTypeKind.dbUnknown
doAssert parseInt(dbCols[21].typ.name) > 0
doAssert dbCols[22].name == "point_col"
doAssert dbCols[22].typ.kind == DbTypeKind.dbPoint
doAssert dbCols[22].typ.name == "point"
doAssert dbCols[23].name == "line_col"
doAssert dbCols[23].typ.kind == DbTypeKind.dbLine
doAssert dbCols[23].typ.name == "line"
doAssert dbCols[24].name == "lseg_col"
doAssert dbCols[24].typ.kind == DbTypeKind.dbLseg
doAssert dbCols[24].typ.name == "lseg"
doAssert dbCols[25].name == "box_col"
doAssert dbCols[25].typ.kind == DbTypeKind.dbBox
doAssert dbCols[25].typ.name == "box"
doAssert dbCols[26].name == "path_col"
doAssert dbCols[26].typ.kind == DbTypeKind.dbPath
doAssert dbCols[26].typ.name == "path"
doAssert dbCols[27].name == "polygon_col"
doAssert dbCols[27].typ.kind == DbTypeKind.dbPolygon
doAssert dbCols[27].typ.name == "polygon"
doAssert dbCols[28].name == "circle_col"
doAssert dbCols[28].typ.kind == DbTypeKind.dbCircle
doAssert dbCols[28].typ.name == "circle"
doAssert dbCols[29].name == "cidr_col"
doAssert dbCols[29].typ.kind == DbTypeKind.dbInet
doAssert dbCols[29].typ.name == "cidr"
doAssert dbCols[30].name == "inet_col"
doAssert dbCols[30].typ.kind == DbTypeKind.dbInet
doAssert dbCols[30].typ.name == "inet"
doAssert dbCols[31].name == "macaddr_col"
doAssert dbCols[31].typ.kind == DbTypeKind.dbMacAddress
doAssert dbCols[31].typ.name == "macaddr"
doAssert dbCols[32].name == "bit_col"
doAssert dbCols[32].typ.kind == DbTypeKind.dbBit
doAssert dbCols[32].typ.name == "bit"
doAssert dbCols[33].name == "varbit_col"
doAssert dbCols[33].typ.kind == DbTypeKind.dbBit
doAssert dbCols[33].typ.name == "bit"
doAssert dbCols[34].name == "tsvector_col"
doAssert dbCols[34].typ.kind == DbTypeKind.dbVarchar
doAssert dbCols[34].typ.name == "tsvector"
doAssert dbCols[35].name == "tsquery_col"
doAssert dbCols[35].typ.kind == DbTypeKind.dbVarchar
doAssert dbCols[35].typ.name == "tsquery"
doAssert dbCols[36].name == "uuid_col"
doAssert dbCols[36].typ.kind == DbTypeKind.dbVarchar
doAssert dbCols[36].typ.name == "uuid"
doAssert dbCols[37].name == "xml_col"
doAssert dbCols[37].typ.kind == DbTypeKind.dbXml
doAssert dbCols[37].typ.name == "xml"
doAssert dbCols[38].name == "json_col"
doAssert dbCols[38].typ.kind == DbTypeKind.dbJson
doAssert dbCols[38].typ.name == "json"
doAssert dbCols[39].name == "array_col"
doAssert dbCols[39].typ.kind == DbTypeKind.dbArray
doAssert dbCols[39].typ.name == "int4[]"
doAssert dbCols[40].name == "custom_composite_col"
doAssert dbCols[40].typ.kind == DbTypeKind.dbUnknown
doAssert parseInt(dbCols[40].typ.name) > 0
doAssert dbCols[41].name == "range_col"
doAssert dbCols[41].typ.kind == DbTypeKind.dbComposite
doAssert dbCols[41].typ.name == "int4range"
# issue 6571
db.exec(sql"DROP TABLE IF EXISTS DICTIONARY")
db.exec(sql("""CREATE TABLE DICTIONARY(
id SERIAL PRIMARY KEY,
entry VARCHAR(1000) NOT NULL,
definition VARCHAR(4000) NOT NULL
);"""))
var entry = "あっそ"
var definition = "(int) (See ああそうそう) oh, really (uninterested)/oh yeah?/hmmmmm"
discard db.getRow(
sql("INSERT INTO DICTIONARY(entry, definition) VALUES(?, ?) RETURNING id"), entry, definition)
doAssert db.getValue(sql"SELECT definition FROM DICTIONARY WHERE entry = ?", entry) == definition
entry = "Format string entry"
definition = "Format string definition"
db.exec(SqlQuery("INSERT INTO DICTIONARY(entry, definition) VALUES (?, ?)"), entry, definition)
doAssert db.getValue(sql"SELECT definition FROM DICTIONARY WHERE entry = ?", entry) == definition
echo("All tests succeeded!")
db.close()