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

Full Unicode support + MariaDB compatibility #27

Merged
merged 12 commits into from
Aug 11, 2016
6 changes: 5 additions & 1 deletion Sources/MySQL/Bind+Node.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
Expand Down
8 changes: 6 additions & 2 deletions Sources/MySQL/Bind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import Core
import JSON

#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
Expand All @@ -18,7 +22,7 @@ public final class Bind {
public typealias CBind = MYSQL_BIND

/// MySQL represents Characters using signed integers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get this comment updated too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can fix that. But I'm also curious why it was written in the first place, because I want to make sure I'm not overlooking something. Maybe @tannernelson will know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to figure that out as well to make sure we're not setting something off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. After further inspection and testing, I think we should be safe. Char is only used while populating the buffer, and MySQL has no concept of "signed" vs "unsigned" - it's just raw bytes in a buffer. So in reality UInt8 accounts for everything Int8 was handling, but it also accounts for the characters that were causing overflow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@collinhundley sounds perfect, I know we generally prefer [UInt8] type. @tannernelson can you give final merge word on this one! You have much more MySQL context.

👍 from me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to get this merged. I need to make some changes to my fork but they'll affect this merge if I push them right now...

typealias Char = Int8
typealias Char = UInt8

/**
The raw C binding.
Expand Down
6 changes: 5 additions & 1 deletion Sources/MySQL/Binds.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
Expand Down
6 changes: 5 additions & 1 deletion Sources/MySQL/Connection.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
Expand Down
7 changes: 6 additions & 1 deletion Sources/MySQL/Database.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
import Core


/**
Holds a `Connection` to the MySQL database.
*/
Expand Down
6 changes: 5 additions & 1 deletion Sources/MySQL/Field+Variant.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
Expand Down
6 changes: 5 additions & 1 deletion Sources/MySQL/Field.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
Expand Down
6 changes: 5 additions & 1 deletion Sources/MySQL/Fields.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#if os(Linux)
import CMySQLLinux
#if MARIADB
import CMariaDBLinux
#else
import CMySQLLinux
#endif
#else
import CMySQLMac
#endif
Expand Down