mcfunley / pugsql

A HugSQL-inspired database library for Python
https://pugsql.org
Apache License 2.0
673 stars 22 forks source link

Update index.md #12

Closed danielk-bud closed 5 years ago

danielk-bud commented 5 years ago

If the leading comment begins with three dashes as shown in the example, I get a ValueError: Statement must have a name. error.

Not sure how to fix it in the lexer so I just thought I'd update the docs and leave this as a note that there's "something up with it". :)

PugSQL Version: 0.1.9

Query file:

--- :name customer_total :one
SELECT
  COUNT(DISTINCT user_id) users
FROM
  transactions

Stack Trace:

Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/uvicorn/main.py", line 306, in run
    loop.run_until_complete(self.serve(sockets=sockets))
  File "uvloop/loop.pyx", line 1451, in uvloop.loop.Loop.run_until_complete
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/uvicorn/main.py", line 313, in serve
    config.load()
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/uvicorn/config.py", line 182, in load
    self.loaded_app = import_from_string(self.app)
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/uvicorn/importer.py", line 20, in import_from_string
    module = importlib.import_module(module_str)
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./app.py", line 30, in <module>
    db = pugsql.module('queries/')
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/pugsql/__init__.py", line 35, in module
    return compiler._module(sqlpath)
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/pugsql/compiler.py", line 151, in _module
    modules[sqlpath] = Module(sqlpath)
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/pugsql/compiler.py", line 45, in __init__
    s = parser.parse(pugsql, ctx=context.Context(sqlfile))
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/pugsql/parser.py", line 38, in parse
    filename=ctx.sqlfile if ctx.sqlfile != '<literal>' else None)
  File "/home/daniel/.local/share/virtualenvs/myproject-bUWJ7r0D/lib/python3.6/site-packages/pugsql/statement.py", line 68, in __init__
    raise ValueError('Statement must have a name.')
ValueError: Statement must have a name.
mcfunley commented 5 years ago

Awesome thank you, I made #13 to look into the underlying problem.

danielk-bud commented 5 years ago

Happy to help. :)