Comments (4)
I just figured that I need to run spatialite_init_ex again.
This is working again, and I also found a null title on the 65th row, so now allow for that ..
do {
try dbQueue!.inDatabase { db in
spatialite_initialize()
var spconnect: OpaquePointer?
spatialite_init_ex(db.sqliteConnection, &spconnect, 0) // NOT verbose
let rows = try Row.fetchCursor(db, sql: sql, arguments: [])
var count = 0
while let row = try rows.next() {
count += 1
MyUtils.Log(TAG, "count=\(count)")
let fid = row["\(fidcolumn!)"] as Int
let wkt = row["wkt"] as String
let title = row["title"] as? String ?? "no title"
let geom = try Geometry(wkt: wkt)
from grdb.swift.
Hello again, @Tybion,
A fatal error is the sign that the Swift code, or the database, has to be changed for the program to be correctly formed.
Here, the message "could not decode String from database value NULL" means that you ask the row for a String
in the column wkt
, but the row contains NULL. There is no such thing as a Swift String
that represents the NULL value. NULL is not the same value as the empty string.
From there, there are several possible solutions, depending on the root problem.
- If the root problem is that the
wkt
column contains NULL when it should not, then alter your database schema and add aNOT NULL
constraint towkt
. Your program will then fail earlier, when it tries to insert a NULL there, and this is where you will apply the necessary fix. - If the root problem is that the program should filter out NULL
wkt
values, then alter the query sql withWHERE wkt IS NOT NULL
. - If the root problem is that the program should be ready for NULL
wkt
values, then alter thewkt
variable type with:let wkt = row["wkt"] as String?
. A NULL value will then be decoded as a nilString?
optional. Alternatively, if you want to process NULL just as if it was the empty string:let wkt: String = row["wkt"] ?? ""
.
When the app starts I get the following, but don't know what is producing this ..
Maps(875,0x202cb3f00) malloc: Unable to set up reclaim buffer (46) - disabling large cache
I don't know what this means.
Final note: I changed the title of the issue so that it can raise the interest of other people who browse the web and search Google for error messages. This question is not about Spatialite, and no issue is personal (as long as we're in the context of support given for free).
from grdb.swift.
Hello, Gwendal. It seems that you missed reading my second message - this has the answer to the problem in my first message. The question is about spatialite and the solution is to run spatialite_init_ex again. I think it is good if you leave 'spatialite' in the issue name so other spatialite+GRDB users find it when searching.
from grdb.swift.
Oh, I'm sorry @Tybion, you're correct I did not properly read your second message. I have restored spatialite in the title, and I'm happy you could fix your issue. It looks like the issue can be closed!
from grdb.swift.
Related Issues (20)
- Question about usage of generated columns HOT 4
- Assertion failed: unexpected NULL value HOT 5
- Confusion over .including(all:) query HOT 6
- How can I do floating-point division on an association count? HOT 8
- Latest version 6.26.0 is not deployed to the Cocoapod HOT 4
- Please add the Privacy Manifest file to the v5.x release. HOT 1
- package 'package.swift' is using Swift tools version 3.1.0 which is no longer supported; consider using '/ swift-tools-version: 5.9' to specify the current tools... HOT 1
- Request: Add citation to the repo HOT 3
- Cocoapods hasn't published since 6.24.1 HOT 2
- Cocoapods 6.26.0 release is not available in Cocapods Specs repo HOT 1
- Privacy Manifest: Entry missing for accessing file timestamps via creationDate API HOT 4
- When transaction updating multiple records in the database, if one of the records does not exist, it leads to update failure. HOT 4
- Avoid conflict with other SPM packages by renaming the CSQLite SPM target
- ValueObservation.tracking called on the updating thread HOT 5
- GRDB does not seem to copy over all rows when inserting within a migration HOT 4
- Unable to decode database NULL value as Swift nil value of type Int? when using ScopeAdapter built from splittingRowAdapters HOT 13
- PlayerRequest.swift is identical in GRDBAsyncDemo and GRDBCombineDemo HOT 4
- App crashes with many (not all) users running iOS 17.4.1 HOT 8
- Library fails to compile when targeting Linux using a SQLite library that doesn't support snapshots HOT 3
- 0xdead10cc prevention — `checkForSuspensionViolation` on every `Statement.step` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grdb.swift.