Skip to content

Added support for casting when Codable. #1327

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

miku1958
Copy link

Although the data stored in SQLite has specified types, these are more for guidance. If an int value is stored as a string, it should be readable as an int. This is the behavior supported by SQLite.

Changes

  • Use LazySequence to delay the creation of Cursor (statement.handle) and the access of Cursor.getValue to match the variable type of Codable.
  • Change subscribe of Cursor to a regular method with throws to bypass the compiler error Ambiguous use of 'xxxxx' and simplify the indentation of get throws.

@miku1958
Copy link
Author

There are some breaking changes:
Array(sqlDB.prepare(table)).first[exp]
fails because the SQL step causes the cache handle to become invalid. I haven't thought of a good solution yet, but it can be changed to
sqlDB.prepare(table).map({ $0[exp] }).first

@miku1958
Copy link
Author

Made some changes. If someone try to use Array.init for prepare, they will get this warning and a runtime error.
image

@nathanfallet nathanfallet self-requested a review July 19, 2025 10:23
@nathanfallet
Copy link
Collaborator

Thanks for your PR! Tell me when it's ready so I can review it and merge it (I saw you're still pushing some code)

@miku1958
Copy link
Author

Hi @nathanfallet I just fixed the lint, it should be ready

@miku1958
Copy link
Author

miku1958 commented Jul 19, 2025

Interesting, SQLite.xcodeproj is not using the SPM.
@nathanfallet could you try again?

@nathanfallet
Copy link
Collaborator

@miku1958 that's because of Cocoapods I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants