88using Microsoft . Data . Sqlite ;
99using magic . lambda . sqlite ;
1010using magic . node . contracts ;
11+ using System . Runtime . InteropServices ;
1112
1213namespace magic . library . internals
1314{
@@ -27,17 +28,24 @@ public async Task Initialize(IRootResolver resolver, SqliteConnection connection
2728 connection . EnableExtensions ( ) ;
2829 using ( var load = connection . CreateCommand ( ) )
2930 {
30- load . CommandText = "select load_extension($p, 'sqlite3_vector_init')" ;
31- load . Parameters . AddWithValue ( "$p" , resolver . RuntimePath ( "sqlite-plugins/vector" ) ) ;
32- _ = await load . ExecuteScalarAsync ( ) ;
31+ var plt = "" ;
32+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
33+ plt = ".dll" ;
34+ else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
35+ plt = ".so" ;
36+ else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
37+ plt = ".dylib" ;
38+ load . CommandText = "select load_extension($p, 'sqlite3_vector_init')" ;
39+ load . Parameters . AddWithValue ( "$p" , resolver . RuntimePath ( "sqlite-plugins/vector" + plt ) ) ;
40+ _ = await load . ExecuteScalarAsync ( ) ;
3341 }
3442 using ( var cmd = connection . CreateCommand ( ) )
3543 {
36- cmd . CommandText = "select vector_init($tbl, $col, $opts);" ;
37- cmd . Parameters . AddWithValue ( "$tbl" , TableName ) ;
38- cmd . Parameters . AddWithValue ( "$col" , ColumnName ) ;
39- cmd . Parameters . AddWithValue ( "$opts" , Options ) ;
40- _ = await cmd . ExecuteScalarAsync ( ) ;
44+ cmd . CommandText = "select vector_init($tbl, $col, $opts);" ;
45+ cmd . Parameters . AddWithValue ( "$tbl" , TableName ) ;
46+ cmd . Parameters . AddWithValue ( "$col" , ColumnName ) ;
47+ cmd . Parameters . AddWithValue ( "$opts" , Options ) ;
48+ _ = await cmd . ExecuteScalarAsync ( ) ;
4149 }
4250 }
4351 }
0 commit comments