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

bug: exportToJSON #600

Open
dtrigo opened this issue Nov 12, 2024 · 0 comments
Open

bug: exportToJSON #600

dtrigo opened this issue Nov 12, 2024 · 0 comments
Labels
bug/fix Something isn't working needs: triage

Comments

@dtrigo
Copy link

dtrigo commented Nov 12, 2024

Plugin version:

6.0.2

Platform(s):

iOS

Current behavior:

SQLite does not have an especific DATE/DATETIME column type, plus the user can store a iso8601 format on a TEXT column.

Trying to make a full export, the code below, does not match any posibility, so it ends up throwing an error. To solve it (I'm far for knowing what I'm doing) I added a date formatter to cover this possibility:

File: ExportToJson

var iso8601formatter = ISO8601DateFormatter()

class func createRowValues(values: [[String: Any]], pos: Int,
                               names: [String],
                               types: [String] ) throws -> [Any] {
        var row: [Any] = []
        for jpos in 0..<names.count {
            if values[pos][names[jpos]] is String  && (TEXTAFFINITY
                                                        .contains(types[jpos].components(separatedBy: "(")[0]
                                                                    .uppercased())
                                                        || BLOBAFFINITY.contains(types[jpos].uppercased())
                                                        || NUMERICAFFINITY.contains(types[jpos].uppercased())
                                                       || iso8601formatter.date(from: values[pos][names[jpos]] as! String) != nil

Expected behavior:

Just making the JSON export

Steps to reproduce:

Declare a column of type text and storing an iso8601 string like "2024-10-24T11:35:00Z"

Related code:

insert short code snippets here

Other information:

Capacitor doctor:

insert the output from `npx cap doctor` here
@dtrigo dtrigo added bug/fix Something isn't working needs: triage labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/fix Something isn't working needs: triage
Projects
None yet
Development

No branches or pull requests

1 participant