@@ -71,7 +71,7 @@ function resolveSource(source: string | CollectionSource | undefined): ResolvedC
7171 }
7272
7373 if ( typeof source === 'string' ) {
74- return defineLocalSource ( { path : source } )
74+ return defineLocalSource ( { include : source } )
7575 }
7676
7777 if ( ( source as ResolvedCollectionSource ) . _resolved ) {
@@ -85,14 +85,6 @@ function resolveSource(source: string | CollectionSource | undefined): ResolvedC
8585 return defineLocalSource ( source )
8686}
8787
88- export function parseSourceBase ( source : CollectionSource ) {
89- const [ fixPart , ...rest ] = source . path . includes ( '*' ) ? source . path . split ( '*' ) : [ '' , source . path ]
90- return {
91- fixed : fixPart || '' ,
92- dynamic : '*' + rest . join ( '*' ) ,
93- }
94- }
95-
9688// Convert collection data to SQL insert statement
9789export function generateCollectionInsert ( collection : ResolvedCollection , data : Record < string , unknown > ) {
9890 const fields : string [ ] = [ ]
@@ -103,7 +95,7 @@ export function generateCollectionInsert(collection: ResolvedCollection, data: R
10395 const value = ( collection . extendedSchema ) . shape [ key ]
10496 const underlyingType = getUnderlyingType ( value as ZodType < unknown , ZodOptionalDef > )
10597
106- let defaultValue = value . _def . defaultValue ? value . _def . defaultValue ( ) : 'NULL'
98+ let defaultValue = value ? ._def . defaultValue ? value ? ._def . defaultValue ( ) : 'NULL'
10799
108100 if ( ! ( defaultValue instanceof Date ) && typeof defaultValue === 'object' ) {
109101 defaultValue = JSON . stringify ( defaultValue )
@@ -138,7 +130,7 @@ export function generateCollectionInsert(collection: ResolvedCollection, data: R
138130export function generateCollectionTableDefinition ( collection : ResolvedCollection , opts : { drop ?: boolean } = { } ) {
139131 const sortedKeys = Object . keys ( ( collection . extendedSchema ) . shape ) . sort ( )
140132 const sqlFields = sortedKeys . map ( ( key ) => {
141- const type = ( collection . extendedSchema ) . shape [ key ]
133+ const type = ( collection . extendedSchema ) . shape [ key ] !
142134 const underlyingType = getUnderlyingType ( type )
143135
144136 if ( key === '_id' ) return `${ key } TEXT PRIMARY KEY`
0 commit comments