aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableSource.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-06-24 20:51:25 +0000
committerrowanbeentje <rowan@beent.je>2009-06-24 20:51:25 +0000
commitcae0a084e52ea3e2e4c1ac92908f41920d9cbbdc (patch)
treea2c4740620d4b1545d228efb28b766cea3e58832 /Source/TableSource.m
parentebce2f66f06a582569b553457000c3f8fed2544a (diff)
downloadsequelpro-cae0a084e52ea3e2e4c1ac92908f41920d9cbbdc.tar.gz
sequelpro-cae0a084e52ea3e2e4c1ac92908f41920d9cbbdc.tar.bz2
sequelpro-cae0a084e52ea3e2e4c1ac92908f41920d9cbbdc.zip
- Fix default values behaviour - previously, default values weren't being saved. They are now.
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r--Source/TableSource.m30
1 files changed, 15 insertions, 15 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 130f9d54..3ead57ac 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -690,31 +690,31 @@ fetches the result as an array with a dictionary for each row in it
if ([[theRow objectForKey:@"Null"] isEqualToString:@"NO"]) {
[queryString appendString:@" NOT NULL"];
- }
- else {
+ } else {
[queryString appendString:@" NULL"];
}
-
- if ((![[theRow objectForKey:@"Extra"] isEqualToString:@"auto_increment"]) &&
- ([[theRow objectForKey:@"Default"] isEqualToString:@"NULL"]))
- {
+
+ // Don't provide any defaults for auto-increment fields
+ if ([[theRow objectForKey:@"Extra"] isEqualToString:@"auto_increment"]) {
+ [queryString appendString:@" "];
+ } else {
+
+ // If a null value has been specified, and null is allowed, specify DEFAULT NULL
if ([[theRow objectForKey:@"Default"] isEqualToString:[prefs objectForKey:@"NullValue"]]) {
if ([[theRow objectForKey:@"Null"] isEqualToString:@"YES"]) {
[queryString appendString:@" DEFAULT NULL "];
}
- }
- else if ([[theRow objectForKey:@"Type"] isEqualToString:@"timestamp"] &&
- ([[theRow objectForKey:@"Default"] isEqualToString:@"CURRENT_TIMESTAMP"] ||
- [[theRow objectForKey:@"Default"] isEqualToString:@"current_timestamp"]) )
+
+ // Otherwise, if current_timestamp was specified for timestamps, use that
+ } else if ([[theRow objectForKey:@"Type"] isEqualToString:@"timestamp"] &&
+ [[[theRow objectForKey:@"Default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"])
{
[queryString appendString:@" DEFAULT CURRENT_TIMESTAMP "];
- }
- else {
+
+ // Otherwise, use the provided default
+ } else {
[queryString appendString:[NSString stringWithFormat:@" DEFAULT '%@' ", [mySQLConnection prepareString:[theRow objectForKey:@"Default"]]]];
}
- }
- else {
- [queryString appendString:@" "];
}
if (!(