Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nixfreak opened this issue Jun 14, 2022 · 0 comments
Open

Comments

@nixfreak
Copy link

"""
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
  
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant