juancarlospaco / nim-gatabase

Connection-Pooling Compile-Time ORM for Nim
https://juancarlospaco.github.io/nim-gatabase
MIT License
120 stars 5 forks source link

Circular dependency with creating more than one table with `createTable` #9

Open nixfreak opened 2 years ago

nixfreak commented 2 years ago

""" nim c -r dbConnect.nim Hint: used config file '/home/nixfreak/.choosenim/toolchains/nim-1.6.6/config/nim.cfg' [Conf] Hint: used config file '/home/nixfreak/.choosenim/toolchains/nim-1.6.6/config/config.nims' [Conf] ................................................................................. /home/nixfreak/.choosenim/toolchains/nim-1.6.6/lib/impure/db_sqlite.nim(184, 1) Warning: Circular dependency detected. codeReordering pragma may not be able to reorder some nodes properly [User] .. /home/nixfreak/nim/myBlog/dbConnect.nim(21, 30) template/generic instantiation of createTable from here /home/nixfreak/nim/myBlog/dbConnect.nim(22, 13) Error: ambiguous call; both dbConnect.:=(dbfieldgensym0: static[string], valuegensym0: typedesc[SomeInteger]) [template declared in /home/nixfreak/.nimble/pkgs/gatabase-0.9.9/gatabase/sugar.nim(92, 12)] and dbConnect.:=(dbfieldgensym21: static[string], valuegensym21: typedesc[SomeInteger]) [template declared in /home/nixfreak/.nimble/pkgs/gatabase-0.9.9/gatabase/sugar.nim(92, 12)] match for: (string, typedesc[int]) """

import std/db_postgres
import gatabase/sugar

# Connect to database (postgres)
let db  = open("localhost", "user", "password", "dbname")
db.close()

let userTable = createTable "users": [
  "id" := int,
  "fullname" := string,
  "username" := string,
  "password" := string
]

let postsTable = createTable "posts": [
  "post_id" := int,
  "author_id" := int,
  "created" := int,
  "title" := string,
  "body" := string

]