mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-05-31 01:11:16 +00:00
* EOAdaptors/SQLiteAdaptor/SQLite3Adaptor.m
add some more potential table column types * EOAdaptors/SQLiteAdaptor/SQLite3Channel.m use the table types from the SQLite3Adaptor to decide about the valueType, and set the NOT NULL correctly git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@36452 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f6d5154771
commit
366670eb69
3 changed files with 58 additions and 30 deletions
|
@ -1,6 +1,12 @@
|
||||||
2013-03-30: Sebastian Reitenbach <sebastia@l00-bugdead-prods.de>
|
2013-03-30: Sebastian Reitenbach <sebastia@l00-bugdead-prods.de>
|
||||||
* Apps/EOModelEditor/SQLGenerator.m
|
* Apps/EOModelEditor/SQLGenerator.m
|
||||||
Add NSEmitTODO to showTables:
|
Add NSEmitTODO to showTables:
|
||||||
|
* EOAdaptors/SQLiteAdaptor/SQLite3Adaptor.m
|
||||||
|
add some more potential table column types
|
||||||
|
* EOAdaptors/SQLiteAdaptor/SQLite3Channel.m
|
||||||
|
use the table types from the SQLite3Adaptor to
|
||||||
|
decide about the valueType, and set the NOT NULL
|
||||||
|
correctly
|
||||||
|
|
||||||
2013-03-25: Sebastian Reitenbach <sebastia@l00-bugdead-prods.de>
|
2013-03-25: Sebastian Reitenbach <sebastia@l00-bugdead-prods.de>
|
||||||
* EOAdaptors/SQLiteAdaptor/SQLite3Channel.m
|
* EOAdaptors/SQLiteAdaptor/SQLite3Channel.m
|
||||||
|
|
|
@ -43,14 +43,36 @@ NSString *SQLite3AdaptorExceptionName = @"SQLite3AdaptorException";
|
||||||
|
|
||||||
static NSString *types[][2] =
|
static NSString *types[][2] =
|
||||||
{
|
{
|
||||||
{@"INTEGER", @"NSDecimalNumber"},
|
{@"INTEGER", @"NSDecimalNumber"},
|
||||||
{@"TEXT", @"NSString"},
|
{@"INT", @"NSDecimalNumber"},
|
||||||
{@"BLOB", @"NSData"},
|
{@"TINYINT", @"NSDecimalNumber"},
|
||||||
{@"DATE", @"NSCalendarDate"},
|
{@"SMALLINT", @"NSDecimalNumber"},
|
||||||
{@"REAL", @"NSNumber"},
|
{@"MEDIUMINT", @"NSDecimalNumber"},
|
||||||
{@"VARCHAR", @"NSString"},
|
{@"BIGINT", @"NSDecimalNumber"},
|
||||||
{@"DOUBLE", @"NSNumber"},
|
{@"UNSIGNED BIGINT", @"NSDecimalNumber"},
|
||||||
{@"NULL", @"EONull"},
|
{@"INT2", @"NSDecimalNumber"},
|
||||||
|
{@"INT8", @"NSDecimalNumber"},
|
||||||
|
{@"TEXT", @"NSString"},
|
||||||
|
{@"CLOB", @"NSString"},
|
||||||
|
{@"CHARACTER", @"NSString"},
|
||||||
|
{@"VARCHAR", @"NSString"},
|
||||||
|
{@"VARYING CHARACTER",@"NSString"},
|
||||||
|
{@"NCHAR", @"NSString"},
|
||||||
|
{@"CHAR", @"NSString"},
|
||||||
|
{@"NATIVE CHARACTER", @"NSString"},
|
||||||
|
{@"NVARCHAR", @"NSString"},
|
||||||
|
{@"BLOB", @"NSData"},
|
||||||
|
{@"REAL", @"NSNumber"},
|
||||||
|
{@"DOUBLE", @"NSNumber"},
|
||||||
|
{@"DOUBLE PRECISION", @"NSNumber"},
|
||||||
|
{@"FLOAT", @"NSNumber"},
|
||||||
|
{@"NUMERIC", @"NSNumber"},
|
||||||
|
{@"DECIMAL", @"NSNumber"},
|
||||||
|
{@"BOOLEAN", @"NSNumber"},
|
||||||
|
{@"BOOL", @"NSNumber"},
|
||||||
|
{@"DATE", @"NSCalendarDate"},
|
||||||
|
{@"DATETIME", @"NSCalendarDate"},
|
||||||
|
{@"NULL", @"EONull"},
|
||||||
};
|
};
|
||||||
|
|
||||||
+ (NSDictionary *)externalToInternalTypeMap
|
+ (NSDictionary *)externalToInternalTypeMap
|
||||||
|
|
|
@ -347,6 +347,7 @@ static id newNumberValue(const char *data, EOAttribute *attrib)
|
||||||
{
|
{
|
||||||
NSString *columnName;
|
NSString *columnName;
|
||||||
NSString *externalType;
|
NSString *externalType;
|
||||||
|
BOOL allowsNull;
|
||||||
for (col=0;col<nCols;col++)
|
for (col=0;col<nCols;col++)
|
||||||
{
|
{
|
||||||
// count keeps track of the current field
|
// count keeps track of the current field
|
||||||
|
@ -360,31 +361,29 @@ static id newNumberValue(const char *data, EOAttribute *attrib)
|
||||||
}
|
}
|
||||||
else if ([tmpHeader isEqual:@"type"])
|
else if ([tmpHeader isEqual:@"type"])
|
||||||
{
|
{
|
||||||
externalType = [NSString stringWithFormat:@"%s", results[count]];
|
NSRange range;
|
||||||
if ([externalType hasPrefix:@"CHAR"] == YES)
|
range = [[NSString stringWithFormat:@"%s", results[count]] rangeOfString:@"("];
|
||||||
{
|
if (range.location != NSNotFound)
|
||||||
valueClass = @"NSString", valueType = @"c";
|
{
|
||||||
}
|
externalType = [[NSString stringWithFormat:@"%s", results[count]] substringToIndex:range.location];
|
||||||
else if ([externalType hasPrefix:@"BOOL"] == YES)
|
}
|
||||||
{
|
else
|
||||||
valueClass = @"NSNumber", valueType = @"c";
|
{
|
||||||
}
|
externalType = [NSString stringWithFormat:@"%s", results[count]];
|
||||||
else if ([externalType hasPrefix:@"INTEGER"] == YES)
|
}
|
||||||
{
|
valueClass = [SQLite3Adaptor internalTypeForExternalType: externalType model:nil];
|
||||||
valueClass = @"NSNumber", valueType = @"l";
|
if (valueClass == nil)
|
||||||
}
|
{
|
||||||
else if ([externalType hasPrefix:@"REAL"] == YES)
|
valueClass = @"NSString";
|
||||||
{
|
// TODO: should also set the valueType here???
|
||||||
valueClass = @"NSNumber", valueType = @"d";
|
}
|
||||||
}
|
|
||||||
else if ([externalType hasPrefix:@"BLOB"] == YES)
|
|
||||||
{
|
|
||||||
valueClass = @"NSData", valueType = @"x";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if ([tmpHeader isEqual:@"notnull"])
|
else if ([tmpHeader isEqual:@"notnull"])
|
||||||
{
|
{
|
||||||
// do nothing yet
|
if ([[NSString stringWithFormat:@"%s", results[count]] isEqual:@"1"])
|
||||||
|
allowsNull = NO;
|
||||||
|
else
|
||||||
|
allowsNull = YES;
|
||||||
}
|
}
|
||||||
else if ([tmpHeader isEqual:@"dflt_value"])
|
else if ([tmpHeader isEqual:@"dflt_value"])
|
||||||
{
|
{
|
||||||
|
@ -400,6 +399,7 @@ static id newNumberValue(const char *data, EOAttribute *attrib)
|
||||||
}
|
}
|
||||||
[attribute setName: columnName];
|
[attribute setName: columnName];
|
||||||
[attribute setColumnName: columnName];
|
[attribute setColumnName: columnName];
|
||||||
|
[attribute setAllowsNull: allowsNull];
|
||||||
[attribute setExternalType: externalType];
|
[attribute setExternalType: externalType];
|
||||||
[attribute setValueType: valueType];
|
[attribute setValueType: valueType];
|
||||||
[attribute setValueClassName: valueClass];
|
[attribute setValueClassName: valueClass];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue