Skip to content

Commit 85d9488

Browse files
committed
fix sqlite double type lost precision
不知道 为什么 sqlite 的double,decimal,float类型 长度 只有 5位。。。 于是 我用 sqlite 列无强制类型的特性。。 把double 类型 都换成了 text 类型
1 parent bd5baa7 commit 85d9488

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

LKDBHelper/Helper/LKDB+Mapping.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ -(id)initWithType:(NSString *)type cname:(NSString *)cname ctype:(NSString *)cty
5656
}
5757
return self;
5858
}
59+
-(NSString *)sqlColumnType
60+
{
61+
if([_sqlColumnType isEqualToString:LKSQL_Type_Double])
62+
{
63+
return LKSQL_Type_Text;
64+
}
65+
return _sqlColumnType;
66+
}
5967
-(void)enableUserCalculate
6068
{
6169
_type = LKSQL_Mapping_UserCalculate;

LKDBHelper/Helper/NSObject+LKModel.m

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ +(NSDictionary *)getTableMapping
6565
return nil;
6666
}
6767
#pragma mark- Table Data Function 表数据
68-
+(NSNumberFormatter*)getNumberFormatter
69-
{
70-
static NSNumberFormatter* format;
71-
static dispatch_once_t onceToken;
72-
dispatch_once(&onceToken, ^{
73-
format = [[NSNumberFormatter alloc]init];
74-
[format setNumberStyle:NSNumberFormatterDecimalStyle];
75-
});
76-
return format;
77-
}
7868
-(id)modelGetValue:(LKDBProperty *)property
7969
{
8070
id value = [self valueForKey:property.propertyName];

LKDBHelper/LKAppDelegate.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ -(void)test
8686
test.color = [UIColor orangeColor];
8787
test.error = @"nil";
8888

89-
test.score = 83.99989989989898989898989;
90-
89+
test.score = [[NSDate date] timeIntervalSince1970];
90+
addText(@"%f",test.score);
9191
//异步 插入第一条 数据 Insert the first
9292
[globalHelper insertToDB:test];
9393

@@ -135,7 +135,7 @@ -(void)test
135135
addText(@"同步搜索 sync search");
136136

137137
NSMutableArray* arraySync = [LKTest searchWithWhere:nil orderBy:nil offset:0 count:100];
138-
for (NSObject* obj in arraySync) {
138+
for (id obj in arraySync) {
139139
addText(@"%@",[obj printAllPropertys]);
140140
}
141141

0 commit comments

Comments
 (0)