From 8aa31fe8d4aab18e8a9d928bd5d67c5639187b60 Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 28 Apr 2017 08:37:59 +0000 Subject: [PATCH] make -simpleExecute: easier to use. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@40495 72102866-910b-0410-8b05-ffd578937521 --- SQLClient.h | 6 ++++-- SQLClient.m | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/SQLClient.h b/SQLClient.h index f497326..d35d856 100644 --- a/SQLClient.h +++ b/SQLClient.h @@ -1016,9 +1016,11 @@ SQLCLIENT_PRIVATE * Calls -backendExecute: in a safe manner.
* Handles locking.
* Maintains -lastOperation date.
- * Returns the result of -backendExecute: + * Returns the result of the -backendExecute: method call.
+ * Accepts a mutable array argument (as produced by the prepare methods) + * or a simple SQL statement (a string), otherwise raises an exception. */ -- (NSInteger) simpleExecute: (NSArray*)info; +- (NSInteger) simpleExecute: (id)info; /** * Calls -simpleQuery:recordType:listType: with the default record class diff --git a/SQLClient.m b/SQLClient.m index 6830c22..5079da6 100644 --- a/SQLClient.m +++ b/SQLClient.m @@ -2441,11 +2441,24 @@ static int poolConnections = 0; [lock unlock]; } -- (NSInteger) simpleExecute: (NSArray*)info +- (NSInteger) simpleExecute: (id)info { NSInteger result; NSString *debug = nil; + if ([info isKindOfClass: NSArrayClass] == NO) + { + if ([info isKindOfClass: NSStringClass] == NO) + { + [NSException raise: NSInvalidArgumentException + format: @"[%@ -simpleExecute: %@ (class %@)]", + NSStringFromClass([self class]), + info, + NSStringFromClass([info class])]; + } + info = [NSMutableArray arrayWithObject: info]; + } + [lock lock]; NS_DURING {