mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-01 19:44:44 +00:00
make more tests green
This commit is contained in:
@@ -128,10 +128,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string =
|
||||
var a = 0
|
||||
for c in items(string(formatstr)):
|
||||
if c == '?':
|
||||
if args[a].isNil:
|
||||
add(result, "NULL")
|
||||
else:
|
||||
add(result, dbQuote(args[a]))
|
||||
add(result, dbQuote(args[a]))
|
||||
inc(a)
|
||||
else:
|
||||
add(result, c)
|
||||
@@ -183,24 +180,8 @@ iterator fastRows*(db: DbConn, query: SqlQuery,
|
||||
row = mysql.fetchRow(sqlres)
|
||||
if row == nil: break
|
||||
for i in 0..L-1:
|
||||
if row[i] == nil:
|
||||
if backup == nil:
|
||||
newSeq(backup, L)
|
||||
if backup[i] == nil and result[i] != nil:
|
||||
shallowCopy(backup[i], result[i])
|
||||
result[i] = nil
|
||||
else:
|
||||
if result[i] == nil:
|
||||
if backup != nil:
|
||||
if backup[i] == nil:
|
||||
backup[i] = ""
|
||||
shallowCopy(result[i], backup[i])
|
||||
setLen(result[i], 0)
|
||||
else:
|
||||
result[i] = ""
|
||||
else:
|
||||
setLen(result[i], 0)
|
||||
add(result[i], row[i])
|
||||
setLen(result[i], 0)
|
||||
result[i].add row[i]
|
||||
yield result
|
||||
properFreeResult(sqlres, row)
|
||||
|
||||
@@ -323,10 +304,7 @@ proc getRow*(db: DbConn, query: SqlQuery,
|
||||
if row != nil:
|
||||
for i in 0..L-1:
|
||||
setLen(result[i], 0)
|
||||
if row[i] == nil:
|
||||
result[i] = nil
|
||||
else:
|
||||
add(result[i], row[i])
|
||||
add(result[i], row[i])
|
||||
properFreeResult(sqlres, row)
|
||||
|
||||
proc getAllRows*(db: DbConn, query: SqlQuery,
|
||||
@@ -345,10 +323,7 @@ proc getAllRows*(db: DbConn, query: SqlQuery,
|
||||
setLen(result, j+1)
|
||||
newSeq(result[j], L)
|
||||
for i in 0..L-1:
|
||||
if row[i] == nil:
|
||||
result[j][i] = nil
|
||||
else:
|
||||
result[j][i] = $row[i]
|
||||
result[j][i] = $row[i]
|
||||
inc(j)
|
||||
mysql.freeResult(sqlres)
|
||||
|
||||
|
||||
@@ -103,10 +103,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string =
|
||||
else:
|
||||
for c in items(string(formatstr)):
|
||||
if c == '?':
|
||||
if args[a] == nil:
|
||||
add(result, "NULL")
|
||||
else:
|
||||
add(result, dbQuote(args[a]))
|
||||
add(result, dbQuote(args[a]))
|
||||
inc(a)
|
||||
else:
|
||||
add(result, c)
|
||||
@@ -179,7 +176,7 @@ proc setRow(res: PPGresult, r: var Row, line, cols: int32) =
|
||||
setLen(r[col], 0)
|
||||
let x = pqgetvalue(res, line, col)
|
||||
if x.isNil:
|
||||
r[col] = nil
|
||||
r[col] = ""
|
||||
else:
|
||||
add(r[col], x)
|
||||
|
||||
|
||||
@@ -105,7 +105,6 @@ proc dbError*(db: DbConn) {.noreturn.} =
|
||||
|
||||
proc dbQuote*(s: string): string =
|
||||
## DB quotes the string.
|
||||
if s.isNil: return "NULL"
|
||||
result = "'"
|
||||
for c in items(s):
|
||||
if c == '\'': add(result, "''")
|
||||
|
||||
@@ -1329,7 +1329,7 @@ when isMainModule:
|
||||
doAssert clearTable[42] == "asd"
|
||||
clearTable.clear()
|
||||
doAssert(not clearTable.hasKey(123123))
|
||||
doAssert clearTable.getOrDefault(42) == nil
|
||||
doAssert clearTable.getOrDefault(42) == ""
|
||||
|
||||
block: #5482
|
||||
var a = [("wrong?","foo"), ("wrong?", "foo2")].newOrderedTable()
|
||||
|
||||
@@ -1869,7 +1869,6 @@ proc entityToUtf8*(entity: string): string =
|
||||
## "" is returned if the entity name is unknown. The HTML parser
|
||||
## already converts entities to UTF-8.
|
||||
runnableExamples:
|
||||
doAssert entityToUtf8(nil) == ""
|
||||
doAssert entityToUtf8("") == ""
|
||||
doAssert entityToUtf8("a") == ""
|
||||
doAssert entityToUtf8("gt") == ">"
|
||||
|
||||
Reference in New Issue
Block a user