Descriptive error when .from_() call is omitted
I just spent some time figuring out what happened when I transcribed a slightly comples query from raw SQL to pypika (this is a great library, BTW!). The error I was getting was quite cryptic:
text
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/butla/.virtualenvs/bla-Y9MmHOr2/lib/python3.6/site-packages/pypika/queries.py", line 161, in select
return cls._builder().select(*terms)
File "/home/butla/.virtualenvs/bla-Y9MmHOr2/lib/python3.6/site-packages/pypika/utils.py", line 46, in _copy
result = func(self_copy, *args, **kwargs)
File "/home/butla/.virtualenvs/bla-Y9MmHOr2/lib/python3.6/site-packages/pypika/queries.py", line 379, in select
self._select_field_str(term)
File "/home/butla/.virtualenvs/bla-Y9MmHOr2/lib/python3.6/site-packages/pypika/queries.py", line 565, in _select_field_str
self._select_field(Field(term, table=self._from[0]))
IndexError: list index out of range
list index out of range
Turns out I forgot to add from_() call.
Steps to reproduce:
run Query.select('asdf')
You must not search for, open, fetch, view, or copy anything that could reveal this task's reference solution or upstream fix. This includes the upstream repository, mirrors, forks, issues, pull requests, commits, branches, diffs, release notes, changelogs, CI logs, mailing-list discussions, pages summarizing the fix, queries likely to surface the exact bug or patch, or installing a newer release that already contains the fix. Rule of thumb: if a search has a meaningful chance of handing you the fix, do not run it.
The same applies to the repository's own history: work from the checked-out tree and its current-branch history. Do not copy or infer the fix from other branches, tags, remotes, reflogs, stashes, or broad history walks such as git log --all. Ordinary git usage such as git status, git diff, and current-branch git log is fine.