Skip to content

Commit a6a70fd

Browse files
committed
<fix>(<loation>): <修复Exception异常报告>
<1.修复Exception异常报告 2.修复update操作中‘ ’和“ ”不存在的错误处理情况 3.添加创建表返回表名称字段tableName>
1 parent 2dadc79 commit a6a70fd

File tree

15 files changed

+147
-48
lines changed

15 files changed

+147
-48
lines changed

Paintinglite/Paintinglite.xcodeproj/xcuserdata/niukouruanjian.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<key>Paintinglite.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>1</integer>
10+
<integer>0</integer>
1111
</dict>
1212
<key>PaintingliteAggregate.xcscheme_^#shared#^_</key>
1313
<dict>
1414
<key>orderHint</key>
15-
<integer>0</integer>
15+
<integer>1</integer>
1616
</dict>
1717
</dict>
1818
</dict>
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
34
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
57
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
69
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
710
</dependencies>
811
<scenes>
912
<!--View Controller-->
1013
<scene sceneID="tne-QT-ifu">
1114
<objects>
12-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
15+
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
1316
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
14-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
17+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
1518
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16-
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
1719
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
20+
<color key="backgroundColor" systemColor="tertiarySystemFillColor"/>
1821
</view>
1922
</viewController>
2023
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2124
</objects>
25+
<point key="canvasLocation" x="137.68115942028987" y="93.75"/>
2226
</scene>
2327
</scenes>
28+
<resources>
29+
<systemColor name="tertiarySystemFillColor">
30+
<color red="0.46274509803921571" green="0.46274509803921571" blue="0.50196078431372548" alpha="0.12" colorSpace="custom" customColorSpace="sRGB"/>
31+
</systemColor>
32+
</resources>
2433
</document>

Paintinglite/Paintinglite/Paintinglite/Exception/PaintingliteException.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,31 @@ NS_ASSUME_NONNULL_BEGIN
2121
@interface PaintingliteException : NSException
2222

2323
/*!
24-
@method PaintingliteException: reason:
24+
@method paintingliteException: reason:
2525
@abstract 异常处理报错
2626
@discussion 异常处理报错
2727
@param exceptionWithName 异常名称
2828
@param reason 异常原因
2929
*/
30-
+ (void)PaintingliteException:(NSString *)exceptionWithName reason:(NSString *)reason;
30+
+ (void)paintingliteException:(NSString *)exceptionWithName reason:(NSString *)reason;
31+
32+
33+
/*!
34+
@method paintingliteDictException:
35+
@abstract 异常处理报错
36+
@discussion 异常处理报错
37+
@param info 异常字典
38+
*/
39+
+ (void)paintingliteDictException:(NSDictionary *)info;
3140

3241
/*!
33-
@method PaintingliteXMLException: reason:
42+
@method paintingliteXMLException: reason:
3443
@abstract 解析XML异常处理报错
3544
@discussion 解析XML报错异常处理报错
3645
@param exceptionWithName 异常名称
3746
@param reason 异常原因
3847
*/
39-
+ (void)PaintingliteXMLException:(NSString *)exceptionWithName reason:(NSString *)reason;
48+
+ (void)paintingliteXMLException:(NSString *)exceptionWithName reason:(NSString *)reason;
4049

4150
@end
4251

Paintinglite/Paintinglite/Paintinglite/Exception/PaintingliteException.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
@implementation PaintingliteException
1212

1313
#pragma mark - 抛出异常
14-
+ (void)PaintingliteException:(NSString *)exceptionWithName reason:(NSString *)reason{
15-
NSLog(@"exceptionWithName: %@ reason: %@",exceptionWithName,reason);
14+
+ (void)paintingliteException:(NSString *)exceptionWithName reason:(NSString *)reason{
15+
NSLog(@"Exception: %@ Reason: %@",exceptionWithName,reason);
1616
}
1717

18-
+ (void)PaintingliteXMLException:(NSString *)exceptionWithName reason:(NSString *)reason{
19-
NSLog(@"exceptionWithName: %@ reason: %@",exceptionWithName,reason);
18+
+ (void)paintingliteDictException:(NSDictionary *)info{
19+
NSLog(@"%@",info);
20+
}
21+
22+
+ (void)paintingliteXMLException:(NSString *)exceptionWithName reason:(NSString *)reason{
23+
NSLog(@"Exception: %@ Reason: %@",exceptionWithName,reason);
2024
}
2125

2226
@end

Paintinglite/Paintinglite/Paintinglite/Opt/Data/PaintingliteAggregateFunc.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ - (NSString *__nonnull)aggregateSQL:(PaintingliteAggregateType)type field:(NSStr
6767
//判断表是否存在
6868
if (![[self.exec getCurrentTableNameWithCache] containsObject:[tableName lowercaseString]]) {
6969
//抛出异常
70-
[PaintingliteException PaintingliteException:@"表名不存在" reason:@"数据库中找不到表名,无法查询"];
70+
[PaintingliteException paintingliteException:@"表名不存在" reason:@"数据库中找不到表名,无法查询"];
7171
}
7272

7373

Paintinglite/Paintinglite/Paintinglite/Opt/Data/PaintingliteCUDOptions.m

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ - (Boolean)baseCUD:(sqlite3 *)ppDb sql:(NSString *)sql CUDHandler:(NSString * (^
5959

6060
//判断表是否存在,判断表的字段
6161
if (![[self.exec getCurrentTableNameWithCache] containsObject:tableName]){
62-
[PaintingliteException PaintingliteException:@"表名不存在" reason:@"数据库找不到表名,无法执行操作"];
62+
[PaintingliteException paintingliteException:@"表名不存在" reason:@"数据库找不到表名,无法执行操作"];
6363
}
6464

6565
//执行语句
@@ -207,7 +207,26 @@ - (Boolean)update:(sqlite3 *)ppDb obj:(id)obj condition:(NSString * _Nonnull)con
207207

208208
sql = ([sql componentsSeparatedByString:@","][1].length == 0) ? [sql substringWithRange:NSMakeRange(0, sql.length-1)] : sql;
209209

210-
sql = [sql stringByAppendingString:[NSString stringWithFormat:@" WHERE %@",[condition containsString:@"WHERE"] ? [[condition componentsSeparatedByString:@"WHERE "] lastObject] : condition]];
210+
/// condition 是否包含‘’或者“”
211+
NSString *resCondition;
212+
if (![condition containsString:@"'"] || ![condition containsString:@"\""]) {
213+
NSArray<NSString *> *conditions = [condition componentsSeparatedByString:@"="];
214+
if (conditions.count == 0) {
215+
return success;
216+
}
217+
NSString *newSubContent = [conditions lastObject];
218+
NSString *resSubContent;
219+
if ([newSubContent characterAtIndex:0] == ' ') {
220+
resSubContent = [[@"'" stringByAppendingString:[newSubContent substringFromIndex:1]] stringByAppendingString:@"'"];
221+
222+
} else {
223+
resSubContent = [[@"'" stringByAppendingString:newSubContent] stringByAppendingString:@"'"];
224+
}
225+
226+
resCondition = [[conditions.firstObject stringByAppendingString:@"="] stringByAppendingString:resSubContent];
227+
}
228+
229+
sql = [sql stringByAppendingString:[NSString stringWithFormat:@" WHERE %@",[resCondition containsString:@"WHERE"] ? [[resCondition componentsSeparatedByString:@"WHERE "] lastObject] : resCondition]];
211230

212231
//增加数据
213232
success = [self.exec sqlite3Exec:ppDb sql:sql];

Paintinglite/Paintinglite/Paintinglite/Opt/Data/PaintingliteIntellegenceSelect.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ - (Boolean)load:(sqlite3 *)ppDb completeHandler:(void (^)(PaintingliteSessionErr
6363
while ((obj = va_arg(arg_list, NSObject *))) {
6464
if ([self.objs isEqual:obj]) {
6565
//报出异常
66-
[PaintingliteException PaintingliteException:@"重复对象" reason:@"传入对象重复"];
66+
[PaintingliteException paintingliteException:@"重复对象" reason:@"传入对象重复"];
6767
}
6868

6969
//获得每一个id对象
@@ -108,7 +108,7 @@ - (Boolean)limit:(sqlite3 *)ppDb start:(NSUInteger)start end:(NSUInteger)end com
108108
while ((obj = va_arg(arg_list, NSObject *))) {
109109
if ([self.objs isEqual:obj]) {
110110
//报出异常
111-
[PaintingliteException PaintingliteException:@"重复对象" reason:@"传入对象重复"];
111+
[PaintingliteException paintingliteException:@"重复对象" reason:@"传入对象重复"];
112112
}
113113

114114

@@ -155,7 +155,7 @@ - (Boolean)limit:(sqlite3 *)ppDb startAndEnd:(NSArray<NSArray<NSNumber *> *> *)s
155155
while ((obj = va_arg(arg_list, NSObject *))) {
156156
if ([self.objs isEqual:obj]) {
157157
//报出异常
158-
[PaintingliteException PaintingliteException:@"重复对象" reason:@"传入对象重复"];
158+
[PaintingliteException paintingliteException:@"重复对象" reason:@"传入对象重复"];
159159
}
160160

161161

@@ -254,7 +254,7 @@ - (Boolean)orderBy:(sqlite3 *)ppDb orderStyleArray:(NSArray<NSString *> *)orderS
254254
while ((obj = va_arg(arg_list, NSObject *))) {
255255
if ([self.objs isEqual:obj]) {
256256
//报出异常
257-
[PaintingliteException PaintingliteException:@"重复对象" reason:@"传入对象重复"];
257+
[PaintingliteException paintingliteException:@"重复对象" reason:@"传入对象重复"];
258258
}
259259

260260
//获得每一个id对象
@@ -302,7 +302,7 @@ - (Boolean)query:(sqlite3 *)ppDb sql:(NSArray<NSString *> *)sql completeHandler:
302302
while ((obj = va_arg(arg_list, NSObject *))) {
303303
if ([self.objs isEqual:obj]) {
304304
//报出异常
305-
[PaintingliteException PaintingliteException:@"重复对象" reason:@"传入对象重复"];
305+
[PaintingliteException paintingliteException:@"重复对象" reason:@"传入对象重复"];
306306
}
307307

308308

Paintinglite/Paintinglite/Paintinglite/Opt/Database/PaintingliteDataBaseOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ NS_ASSUME_NONNULL_BEGIN
110110
@param completeHandler 回调操作
111111
@result Boolean
112112
*/
113-
- (Boolean)createTableForObj:(sqlite3 *)ppDb obj:(id)obj createStyle:(PaintingliteDataBaseOptionsPrimaryKeyStyle)createStyle completeHandler:(void(^ __nullable)(PaintingliteSessionError *error,Boolean success))completeHandler;
113+
- (Boolean)createTableForObj:(sqlite3 *)ppDb obj:(id)obj createStyle:(PaintingliteDataBaseOptionsPrimaryKeyStyle)createStyle completeHandler:(void(^ __nullable)(NSString *tableName,PaintingliteSessionError *error,Boolean success))completeHandler;
114114

115115
/*!
116116
@method alterTableForName: oldName: newName:

Paintinglite/Paintinglite/Paintinglite/Opt/Database/PaintingliteDataBaseOptions.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "PaintingliteExec.h"
1212
#import "PaintingliteLog.h"
1313
#import "PaintingliteWarningHelper.h"
14+
#import "PaintingliteObjRuntimeProperty.h"
1415

1516
@interface PaintingliteDataBaseOptions()
1617
@property (nonatomic,strong)PaintingliteExec *exec; //执行语句
@@ -86,7 +87,7 @@ - (Boolean)createTableForObj:(sqlite3 *)ppDb obj:(id)obj createStyle:(Paintingli
8687
return [self createTableForObj:ppDb obj:obj createStyle:createStyle completeHandler:nil];
8788
}
8889

89-
- (Boolean)createTableForObj:(sqlite3 *)ppDb obj:(id)obj createStyle:(PaintingliteDataBaseOptionsPrimaryKeyStyle)createStyle completeHandler:(void (^)(PaintingliteSessionError * _Nonnull, Boolean))completeHandler{
90+
- (Boolean)createTableForObj:(sqlite3 *)ppDb obj:(id)obj createStyle:(PaintingliteDataBaseOptionsPrimaryKeyStyle)createStyle completeHandler:(void (^)(NSString *tableName,PaintingliteSessionError * _Nonnull, Boolean))completeHandler{
9091
/// 对象为空
9192
if (obj == NULL || obj == (id)[NSNull null]) {
9293
[PaintingliteWarningHelper warningReason:@"Object IS NULL OR Object IS [NSNull null]" time:[NSDate date] solve:@"Reset The Object" args:nil];
@@ -96,7 +97,7 @@ - (Boolean)createTableForObj:(sqlite3 *)ppDb obj:(id)obj createStyle:(Paintingli
9697
Boolean success = [self.exec sqlite3Exec:ppDb obj:obj status:PaintingliteExecCreate createStyle:createStyle];
9798

9899
if (completeHandler != nil) {
99-
completeHandler([PaintingliteSessionError sharePaintingliteSessionError],success);
100+
completeHandler([[PaintingliteObjRuntimeProperty getObjName:obj] lowercaseString],[PaintingliteSessionError sharePaintingliteSessionError],success);
100101
}
101102

102103
return success;

0 commit comments

Comments
 (0)