Hacker News new | ask | show | jobs
by a2tech 4311 days ago
This is super slick. SQLite is so elegant, and this should stop people from reinventing the wheel over and over again.
1 comments

I hope somebody reinvents this library.

I know it's hard to release something to the public, and easy to throw stones. But I'm going to do it anyway. I just don't see the “elegance” in this library and I see several problems with this library that make it unsuitable for production use. Examples:

This library provides access to a singleton database. Did you want to choose the location of your database? Sorry, it's going to be “SwiftData.sqlite” in your app's Documents folder (if sandbox) or the user's “Documents” folder (if not sandboxed). Did you want to use a SQLite3 database as your document storage format, and let the user have multiple documents open simultaneously? Sorry, not with this library.

This library doesn't use prepared statements. When you give it SQL with bind placeholders and substitution values, it creates a new string that embeds the values. Does your SQL statement have a string literal containing a `?`? Sorry, this library will treat it as a bind placeholder anyway. (Example: the ? here is not a placeholder: insert into x values ('?')) Did you want to use less error-prone named placeholders, which SQLite3 supports natively? Sorry, not with this library.

This library loads the entire result set of a query into an array and returns it to you. Did you want to reduce your memory footprint? Sorry, not with this library.

The library source code is full of copy-pasted code that should be unified.

Every enumeration case in the standard library (c.f. Bit, Character, FloatingPointClassification, ImplicitlyUnwrappedOptional, MirrorDisposition, Optional, QuickLookObject, UnicodeDecodingResult) starts with a capital letter. This library's enumeration cases (c.f. DataType, Flags) start with lower case letters.