File tree Expand file tree Collapse file tree 2 files changed +2
-29
lines changed Expand file tree Collapse file tree 2 files changed +2
-29
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ use sqlite_nostd as sqlite;
67
67
use sqlite_nostd:: { Connection , Context , Value } ;
68
68
use tableinfo:: { crsql_ensure_table_infos_are_up_to_date, is_table_compatible, pull_table_info} ;
69
69
use teardown:: * ;
70
- use triggers:: recreate_update_triggers ;
70
+ use triggers:: create_triggers ;
71
71
72
72
pub extern "C" fn crsql_as_table (
73
73
ctx : * mut sqlite:: context ,
@@ -667,7 +667,7 @@ unsafe extern "C" fn x_crsql_commit_alter(
667
667
let rc = if non_destructive {
668
668
match pull_table_info ( db, table_name, & mut err_msg as * mut _ ) {
669
669
Ok ( table_info) => {
670
- match recreate_update_triggers ( db, & table_info, & mut err_msg as * mut _ ) {
670
+ match create_triggers ( db, & table_info, & mut err_msg) {
671
671
Ok ( ResultCode :: OK ) => {
672
672
// need to ensure the right table infos in ext data
673
673
crsql_ensure_table_infos_are_up_to_date (
Original file line number Diff line number Diff line change @@ -9,33 +9,6 @@ use sqlite_nostd as sqlite;
9
9
10
10
use crate :: tableinfo:: TableInfo ;
11
11
12
- pub fn recreate_update_triggers (
13
- db : * mut sqlite3 ,
14
- table_info : & TableInfo ,
15
- err : * mut * mut c_char ,
16
- ) -> Result < ResultCode , ResultCode > {
17
- db. exec_safe ( & format ! (
18
- "DROP TRIGGER IF EXISTS \" {table}__crsql_utrig\" " ,
19
- table = crate :: util:: escape_ident( & table_info. tbl_name)
20
- ) ) ?;
21
-
22
- // get all columns of table
23
- // iterate pk cols
24
- // drop triggers against those pk cols
25
- let stmt = db. prepare_v2 ( "SELECT name FROM pragma_table_info(?) WHERE pk > 0" ) ?;
26
- stmt. bind_text ( 1 , & table_info. tbl_name , sqlite:: Destructor :: STATIC ) ?;
27
- while stmt. step ( ) ? == ResultCode :: ROW {
28
- let col_name = stmt. column_text ( 0 ) ?;
29
- db. exec_safe ( & format ! (
30
- "DROP TRIGGER IF EXISTS \" {tbl_name}_{col_name}__crsql_utrig\" " ,
31
- tbl_name = crate :: util:: escape_ident( & table_info. tbl_name) ,
32
- col_name = crate :: util:: escape_ident( col_name) ,
33
- ) ) ?;
34
- }
35
-
36
- create_update_trigger ( db, table_info, err)
37
- }
38
-
39
12
pub fn create_triggers (
40
13
db : * mut sqlite3 ,
41
14
table_info : & TableInfo ,
You can’t perform that action at this time.
0 commit comments