File tree Expand file tree Collapse file tree 3 files changed +80
-291
lines changed
Expand file tree Collapse file tree 3 files changed +80
-291
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,15 @@ export class FileSystemDriver implements Driver {
216216 * Create a new record.
217217 */
218218 async create ( objectName : string , data : any , options ?: any ) : Promise < any > {
219+ // Validate object name
220+ if ( ! objectName || objectName . trim ( ) === '' ) {
221+ throw new ObjectQLError ( {
222+ code : 'INVALID_OBJECT_NAME' ,
223+ message : 'Object name cannot be empty' ,
224+ details : { objectName }
225+ } ) ;
226+ }
227+
219228 const records = this . loadRecords ( objectName ) ;
220229
221230 // Generate ID if not provided
@@ -314,8 +323,10 @@ export class FileSystemDriver implements Driver {
314323 actualFilters = filters . filters ;
315324 }
316325
317- // If no filters, return total count
318- if ( ! actualFilters || ( Array . isArray ( actualFilters ) && actualFilters . length === 0 ) ) {
326+ // If no filters or empty object/array, return total count
327+ if ( ! actualFilters ||
328+ ( Array . isArray ( actualFilters ) && actualFilters . length === 0 ) ||
329+ ( typeof actualFilters === 'object' && ! Array . isArray ( actualFilters ) && Object . keys ( actualFilters ) . length === 0 ) ) {
319330 return records . length ;
320331 }
321332
Original file line number Diff line number Diff line change @@ -72,6 +72,10 @@ describe('FileSystemDriver', () => {
7272
7373 test ( 'should update a record' , async ( ) => {
7474 const created = await driver . create ( 'users' , { name : 'David' , age : 25 } ) ;
75+
76+ // Add small delay to ensure different timestamp
77+ await new Promise ( resolve => setTimeout ( resolve , 10 ) ) ;
78+
7579 const updated = await driver . update ( 'users' , created . id , { age : 26 } ) ;
7680
7781 expect ( updated . age ) . toBe ( 26 ) ;
You can’t perform that action at this time.
0 commit comments