Skip to content

Commit

Permalink
Merge pull request #120 from itsumura-h/hotfix/pg_double_quote
Browse files Browse the repository at this point in the history
upper case for select column
  • Loading branch information
itsumura-h authored Oct 15, 2020
2 parents 07d2158 + 03de3a2 commit 51a2b06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions example/config.nims
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os

# DB Connection
putEnv("DB_DRIVER", "sqlite")
putEnv("DB_CONNECTION", "/root/project/example/db.sqlite3")
# putEnv("DB_DRIVER", "sqlite")
# putEnv("DB_CONNECTION", "/root/project/example/db.sqlite3")
# putEnv("DB_DRIVER", "mysql")
# putEnv("DB_CONNECTION", "mysql:3306")
# putEnv("DB_DRIVER", "postgres")
# putEnv("DB_CONNECTION", "postgres:5432")
putEnv("DB_DRIVER", "postgres")
putEnv("DB_CONNECTION", "postgres:5432")
putEnv("DB_USER", "user")
putEnv("DB_PASSWORD", "Password!")
putEnv("DB_DATABASE", "allographer")
Expand Down
3 changes: 3 additions & 0 deletions example/upperCase.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import json
import ../src/allographer/query_builder

discard RDB().table("world").where("id", "=", 1).updateSql(%*{"randomnumber": 2})
discard RDB().table("World").where("Id", "=", 1).updateSql(%*{"randomNumber": 2})
discard RDB().table("world").select("id", "randomnumber").where("id", "=", 1).selectSql()
discard RDB().table("World").select("id", "randomNumber").where("Id", "=", 1).selectSql()
4 changes: 3 additions & 1 deletion src/allographer/query_builder/generators.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ proc selectSql*(this: RDB): RDB =
if this.query.hasKey("select"):
for i, item in this.query["select"].getElems():
if i > 0: queryString.add(",")
queryString.add(&" {item.getStr()}")
var column = item.getStr()
wrapUpper(column)
queryString.add(&" {column}")
else:
queryString.add(" *")

Expand Down

0 comments on commit 51a2b06

Please sign in to comment.