-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from adriencanterot/fix/unicode
Fix unicode string length not being interpreted right by SQLite
- Loading branch information
Showing
3 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,7 @@ extension SQLite { | |
} | ||
|
||
public func bind(_ value: String) throws { | ||
let strlen = Int32(value.characters.count) | ||
let strlen = Int32(value.utf8CString.count) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tanner0101
Author
Member
|
||
if sqlite3_bind_text(pointer, nextBindPosition, value, strlen, SQLITE_TRANSIENT) != SQLITE_OK { | ||
throw SQLiteError.bind(database.errorMessage) | ||
} | ||
|
@@ -231,7 +231,7 @@ extension SQLite { | |
try bind(value ? 1 : 0) | ||
} | ||
|
||
//binds a null value, useful for inserting new rows without having to put an id | ||
|
||
public func null() throws { | ||
if sqlite3_bind_null(pointer, nextBindPosition) != SQLITE_OK { | ||
throw SQLiteError.bind(database.errorMessage) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import XCTest | ||
@testable import SQLite | ||
|
||
extension SQLite { | ||
static func makeTestConnection() -> SQLite? { | ||
do { | ||
let sqlite = try SQLite(path:"test_database.sqlite") | ||
return sqlite | ||
|
||
} catch { | ||
XCTFail() | ||
} | ||
return nil | ||
} | ||
} |
This change actually messes up quite a lot for me. I cannot properly read data using DB Browser for SQLite anymore, text is shown as blobs. Also filtering on ID's does not work correctly anymore. I'm not exactly sure what should be changed, but this does not seem like the correct solution.