Commits

Tuukka Norri committed 5517bbe

Added methods for checking null constraint (references #31, references #53)

Comments (0)

Files changed (2)

Framework/Sources/PGTSFieldInfo.h

     unsigned int index;
     unsigned int indexInResultSet;
     Oid typeOid;
+	BOOL isNotNull;
 }
 
 - (unsigned int) index;
 - (Oid) typeOid;
 - (NSString *) qualifiedName;
 - (NSComparisonResult) indexCompare: (PGTSFieldInfo *) aField;
+- (BOOL) isNotNull;
 
 @end

Framework/Sources/PGTSFieldInfo.m

 {
     if (nil == name && index != 0)
     {
-        PGTSResultSet* res = [connection executeQuery: @"SELECT attname, atttypid FROM pg_attribute WHERE attrelid = $1 AND attnum = $2"
+        PGTSResultSet* res = [connection executeQuery: @"SELECT attname, atttypid, attnotnull FROM pg_attribute WHERE attrelid = $1 AND attnum = $2"
                                            parameters: PGTSOidAsObject ([table oid]), [NSNumber numberWithUnsignedInt: index]];
         if ([res advanceRow])
         {
             [self setName: [res valueForFieldNamed: @"attname"]];
             typeOid = [[res valueForFieldNamed: @"atttypid"] PGTSOidValue];
+			isNotNull = [[res valueForFieldNamed: @"attnotnull"] boolValue];
         }
     }
     return name;
 {
     if (index == 0 && nil != name)
     {
-        PGTSResultSet* res = [connection executeQuery: @"SELECT attnumber, atttypid FROM pg_attribute WHERE attrelid = $1 AND attname = $2"
+        PGTSResultSet* res = [connection executeQuery: @"SELECT attnumber, atttypid, attnotnull FROM pg_attribute WHERE attrelid = $1 AND attname = $2"
                                            parameters: PGTSOidAsObject ([table oid]), name];
         [self setIndex: [[res valueForFieldNamed: @"attnumber"] unsignedIntValue]];
         typeOid = [[res valueForFieldNamed: @"atttypid"] PGTSOidValue];
+		isNotNull = [[res valueForFieldNamed: @"attnotnull"] boolValue];
     }
     return index;
 }
     return result;
 }
 
+- (BOOL) isNotNull
+{
+	return isNotNull;
+}
+
 @end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.