@@ -9,7 +9,6 @@ local function safeParameters(params)
99 end
1010
1111 assert (type (params ) == " table" , " A table is expected" )
12- assert (params [1 ] == nil , " Parameters should not be an array, but a map (key / value pair) instead" )
1312
1413 if next (params ) == nil then
1514 return {[' ' ] = ' ' }
2726-- @return int Number of rows updated
2827--
2928function MySQL .Sync .execute (query , params )
30- assert (type (query ) == " string" , " The SQL Query must be a string" )
29+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
3130
3231 local res = 0
3332 local finishedQuery = false
4746-- @return table Query results
4847--
4948function MySQL .Sync .fetchAll (query , params )
50- assert (type (query ) == " string" , " The SQL Query must be a string" )
49+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
5150
5251 local res = {}
5352 local finishedQuery = false
6968-- @return mixed Value of the first column in the first row
7069--
7170function MySQL .Sync .fetchScalar (query , params )
72- assert (type (query ) == " string" , " The SQL Query must be a string" )
71+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
7372
7473 local res = ' '
7574 local finishedQuery = false
9089-- @return mixed Value of the last insert id
9190--
9291function MySQL .Sync .insert (query , params )
93- assert (type (query ) == " string" , " The SQL Query must be a string" )
92+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
9493
9594 local res = 0
9695 local finishedQuery = false
147146-- @param func(int)
148147--
149148function MySQL .Async .execute (query , params , func )
150- assert (type (query ) == " string" , " The SQL Query must be a string" )
149+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
151150
152151 exports [' mysql-async' ]:mysql_execute (query , safeParameters (params ), func )
153152end
160159-- @param func(table)
161160--
162161function MySQL .Async .fetchAll (query , params , func )
163- assert (type (query ) == " string" , " The SQL Query must be a string" )
162+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
164163
165164 exports [' mysql-async' ]:mysql_fetch_all (query , safeParameters (params ), func )
166165end
174173-- @param func(mixed)
175174--
176175function MySQL .Async .fetchScalar (query , params , func )
177- assert (type (query ) == " string" , " The SQL Query must be a string" )
176+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
178177
179178 exports [' mysql-async' ]:mysql_fetch_scalar (query , safeParameters (params ), func )
180179end
187186-- @param func(string)
188187--
189188function MySQL .Async .insert (query , params , func )
190- assert (type (query ) == " string" , " The SQL Query must be a string" )
189+ assert (type (query ) == " string" or type ( query ) == " number " , " The SQL Query must be a string" )
191190
192191 exports [' mysql-async' ]:mysql_insert (query , safeParameters (params ), func )
193192end
0 commit comments