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

Convert raw SQL strings to use SQLite.swift types #1026

Open
mplorentz opened this issue Dec 13, 2022 · 0 comments
Open

Convert raw SQL strings to use SQLite.swift types #1026

mplorentz opened this issue Dec 13, 2022 · 0 comments
Labels
tech A label for technical debt or technology upgrades.

Comments

@mplorentz
Copy link
Member

We have written a lot of SQL queries as plain strings, especially in the new FeedStrategy subclasses. These queries are sometimes easier to read for those familiar with SQL, but there is no good way to compose strings of SQL, so we have ended up with a lot of duplicate code. This makes database changes (like adding a column to the message table) very expensive and error prone. It's also caused us to need ugly workarounds to namespace tables, for instance in Message+ViewDatabase.swift.

Let's refactor our raw strings to use SQLite.swift commands. This will increase code reuse and allow us to write new queries faster in the future. There may be a few edge cases where SQLite.swift doesn't have an API for some advanced SQL features. In those cases it's ok to stick with raw SQL and db.execute().

@mplorentz mplorentz converted this from a draft issue Dec 13, 2022
@mplorentz mplorentz added the tech A label for technical debt or technology upgrades. label Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech A label for technical debt or technology upgrades.
Projects
None yet
Development

No branches or pull requests

1 participant