Allow overriding of default quoting behaviour
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
The issue points to Expression(literal: ...) and the quoted identifiers generated when columns are fetched; start by tracing those paths in the Swift/SQLite.swift codebase. Decide whether case-by-case quoting can be overridden without breaking identifier lookup, or document the SQLite peculiarity if it cannot; done should be demonstrated by a focused example or documentation update.
Written by the indexing model from the issue text.
Description
Yep. For now, everything's quoted where it can be and because of this, relying and detecting dots is problematic because you could, in theory, have a table name with a period in it.
(from #30)
A downside of using quoted identifiers everywhere is that db errors might get obscured, e.g. in this example from the documentation:
let count = try db.scalar(users.filter(name != nil).count)
// SELECT count(*) FROM "users" WHERE "name" IS NOT NULL
A missing name column will not raise an error. The reason is that identifiers can get reinterpreted as strings if the identifier is not found:
If a keyword in double quotes (ex: "key" or "glob") is used in a context where it cannot be resolved to an identifier but where a string literal is allowed, then the token is understood to be a string literal instead of an identifier.
(https://www.sqlite.org/lang_keywords.html)
Richard Hipp called this a "tragic design error":
The fact that SQLite will treat a double-quoted string as a string literal
rather than as a quoted identifier is a horrible mis-feature. It was added
10 years or so ago in an attempt to be more MySQL-compatible. I have come
to sorely regret that change. I'd love to get rid of this mis-feature, but
cannot do so now, since there are millions of applications in the wild that
use SQLite and some percentage of those (hopefully a very small percentage,
but still non-zero) will break if I remove the mis-feature.
The point is that allowing double-quoted strings is a tragic design error.
It's not really SQLite.swift's fault, but it would be good if the quoting could be overridden on a case-by- case basis.
I tried Expression<T>(literal: ...) but that does not work since column names are also quoted when fetched from the database. Even if this is not addressed in SQLite.swift itself it might be helpful to mention this peculiarity somewhere in the documentation.
- Dominant language
- Swift
- Stars
- 10.2k
- Forks
- 1.6k
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stephencelis/SQLite.swift
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
stephencelis/SQLite.swift#1375 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
stephencelis/SQLite.swift#1293 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
stephencelis/SQLite.swift#1347 · 7 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
stephencelis/SQLite.swift#1338 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
stephencelis/SQLite.swift#1337 · 3 comments ·
All issues in stephencelis/SQLite.swift
Similar issues
-
tvOS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
skiptools/skip-fuse-ui#147 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OneBusAway/onebusaway-ios#1438 · 1 reaction ·