aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPSQLExporter.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-07-15 10:57:32 +0000
committerstuconnolly <stuart02@gmail.com>2010-07-15 10:57:32 +0000
commitb21ab51d37672f7e5934938d0ffde641f4de3a26 (patch)
tree0a2b670bebcaa55e046019794270beac0a699f6e /Source/SPSQLExporter.m
parent11bd9d4da5e42d5914b50c1f149d38ce6df863e7 (diff)
downloadsequelpro-b21ab51d37672f7e5934938d0ffde641f4de3a26.tar.gz
sequelpro-b21ab51d37672f7e5934938d0ffde641f4de3a26.tar.bz2
sequelpro-b21ab51d37672f7e5934938d0ffde641f4de3a26.zip
Improve handling of BIT fields, including:
- Exporting BIT fields properly in SQL dumps using b'x' notation. - Properly handling editing of BIT fields in both the content and custom query results views. - Correctly display BIT fields in the content view, where binary values are zero-padded to the specified length of the field. (Note, that the new BIT handling logic has only been added to MCPKit's MCPStreamingResult and MCPResult as the latter does not keep a record of the field's length which the new functionality depends on. Needs to be discussed).
Diffstat (limited to 'Source/SPSQLExporter.m')
-rw-r--r--Source/SPSQLExporter.m11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m
index ad16a119..683e3a48 100644
--- a/Source/SPSQLExporter.m
+++ b/Source/SPSQLExporter.m
@@ -365,11 +365,17 @@
}
id object = NSArrayObjectAtIndex(row, t);
-
+
// Add NULL values directly to the output row
if ([object isMemberOfClass:[NSNull class]]) {
[sqlString appendString:@"NULL"];
}
+ // If the field is off type BIT, the values need a binary prefix of b'x'.
+ else if ([[NSArrayObjectAtIndex([tableDetails objectForKey:@"columns"], t) objectForKey:@"type"] isEqualToString:@"BIT"]) {
+ [sqlString appendString:@"b'"];
+ [sqlString appendString:[object description]];
+ [sqlString appendString:@"'"];
+ }
// Add data types directly as hex data
else if ([object isKindOfClass:[NSData class]]) {
@@ -400,8 +406,7 @@
if ([cellValue length] == 0) {
[sqlString appendString:@"''"];
}
- else {
- // If this is a numeric column type, add the number directly.
+ else {
if ([NSArrayObjectAtIndex(tableColumnNumericStatus, t) boolValue]) {
[sqlString appendString:cellValue];
}