Skip to content

Commit b4ae9ae

Browse files
committed
chore: migrate positional parameters from ?N to $N across codebase
1 parent b328312 commit b4ae9ae

File tree

7 files changed

+190
-190
lines changed

7 files changed

+190
-190
lines changed

src/db.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,9 @@ pub(crate) mod test {
655655

656656
// Filter
657657
{
658-
let statement = kite_sql.prepare("explain select * from t1 where b > ?1")?;
658+
let statement = kite_sql.prepare("explain select * from t1 where b > $1")?;
659659

660-
let mut iter = kite_sql.execute(&statement, &[("?1", DataValue::Int32(0))])?;
660+
let mut iter = kite_sql.execute(&statement, &[("$1", DataValue::Int32(0))])?;
661661

662662
assert_eq!(
663663
iter.next().unwrap()?.values[0].utf8().unwrap(),
@@ -669,16 +669,16 @@ pub(crate) mod test {
669669
// Aggregate
670670
{
671671
let statement = kite_sql.prepare(
672-
"explain select a + ?1, max(b + ?2) from t1 where b > ?3 group by a + ?4",
672+
"explain select a + $1, max(b + $2) from t1 where b > $3 group by a + $4",
673673
)?;
674674

675675
let mut iter = kite_sql.execute(
676676
&statement,
677677
&[
678-
("?1", DataValue::Int32(0)),
679-
("?2", DataValue::Int32(0)),
680-
("?3", DataValue::Int32(1)),
681-
("?4", DataValue::Int32(0)),
678+
("$1", DataValue::Int32(0)),
679+
("$2", DataValue::Int32(0)),
680+
("$3", DataValue::Int32(1)),
681+
("$4", DataValue::Int32(0)),
682682
],
683683
)?;
684684
assert_eq!(
@@ -690,15 +690,15 @@ pub(crate) mod test {
690690
)
691691
}
692692
{
693-
let statement = kite_sql.prepare("explain select *, ?1 from (select * from t1 where b > ?2) left join (select * from t1 where a > ?3) on a > ?4")?;
693+
let statement = kite_sql.prepare("explain select *, $1 from (select * from t1 where b > $2) left join (select * from t1 where a > $3) on a > $4")?;
694694

695695
let mut iter = kite_sql.execute(
696696
&statement,
697697
&[
698-
("?1", DataValue::Int32(9)),
699-
("?2", DataValue::Int32(0)),
700-
("?3", DataValue::Int32(1)),
701-
("?4", DataValue::Int32(0)),
698+
("$1", DataValue::Int32(9)),
699+
("$2", DataValue::Int32(0)),
700+
("$3", DataValue::Int32(1)),
701+
("$4", DataValue::Int32(0)),
702702
],
703703
)?;
704704
assert_eq!(

tpcc/src/delivery.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ impl TpccTransaction for Delivery {
5050
let tuple = tx.query_one(
5151
&statements[0],
5252
&[
53-
("?1", DataValue::Int8(d_id as i8)),
54-
("?2", DataValue::Int16(args.w_id as i16)),
53+
("$1", DataValue::Int8(d_id as i8)),
54+
("$2", DataValue::Int16(args.w_id as i16)),
5555
],
5656
)?;
5757
let no_o_id = tuple.values[0].i32().unwrap();
@@ -63,59 +63,59 @@ impl TpccTransaction for Delivery {
6363
tx.execute_drain(
6464
&statements[1],
6565
&[
66-
("?1", DataValue::Int32(no_o_id)),
67-
("?2", DataValue::Int8(d_id as i8)),
68-
("?3", DataValue::Int16(args.w_id as i16)),
66+
("$1", DataValue::Int32(no_o_id)),
67+
("$2", DataValue::Int8(d_id as i8)),
68+
("$3", DataValue::Int16(args.w_id as i16)),
6969
],
7070
)?;
7171
// "SELECT o_c_id FROM orders WHERE o_id = ? AND o_d_id = ? AND o_w_id = ?"
7272
let tuple = tx.query_one(
7373
&statements[2],
7474
&[
75-
("?1", DataValue::Int32(no_o_id)),
76-
("?2", DataValue::Int8(d_id as i8)),
77-
("?3", DataValue::Int16(args.w_id as i16)),
75+
("$1", DataValue::Int32(no_o_id)),
76+
("$2", DataValue::Int8(d_id as i8)),
77+
("$3", DataValue::Int16(args.w_id as i16)),
7878
],
7979
)?;
8080
let c_id = tuple.values[0].i32().unwrap();
8181
// "UPDATE orders SET o_carrier_id = ? WHERE o_id = ? AND o_d_id = ? AND o_w_id = ?"
8282
tx.execute_drain(
8383
&statements[3],
8484
&[
85-
("?1", DataValue::Int8(args.o_carrier_id as i8)),
86-
("?2", DataValue::Int32(no_o_id)),
87-
("?3", DataValue::Int8(d_id as i8)),
88-
("?4", DataValue::Int16(args.w_id as i16)),
85+
("$1", DataValue::Int8(args.o_carrier_id as i8)),
86+
("$2", DataValue::Int32(no_o_id)),
87+
("$3", DataValue::Int8(d_id as i8)),
88+
("$4", DataValue::Int16(args.w_id as i16)),
8989
],
9090
)?;
9191
// "UPDATE order_line SET ol_delivery_d = ? WHERE ol_o_id = ? AND ol_d_id = ? AND ol_w_id = ?"
9292
tx.execute_drain(
9393
&statements[4],
9494
&[
95-
("?1", DataValue::from(&now)),
96-
("?2", DataValue::Int32(no_o_id)),
97-
("?3", DataValue::Int8(d_id as i8)),
98-
("?4", DataValue::Int16(args.w_id as i16)),
95+
("$1", DataValue::from(&now)),
96+
("$2", DataValue::Int32(no_o_id)),
97+
("$3", DataValue::Int8(d_id as i8)),
98+
("$4", DataValue::Int16(args.w_id as i16)),
9999
],
100100
)?;
101101
// "SELECT SUM(ol_amount) FROM order_line WHERE ol_o_id = ? AND ol_d_id = ? AND ol_w_id = ?"
102102
let tuple = tx.query_one(
103103
&statements[5],
104104
&[
105-
("?1", DataValue::Int32(no_o_id)),
106-
("?2", DataValue::Int8(d_id as i8)),
107-
("?3", DataValue::Int16(args.w_id as i16)),
105+
("$1", DataValue::Int32(no_o_id)),
106+
("$2", DataValue::Int8(d_id as i8)),
107+
("$3", DataValue::Int16(args.w_id as i16)),
108108
],
109109
)?;
110110
let ol_total = tuple.values[0].decimal().unwrap();
111111
// "UPDATE customer SET c_balance = c_balance + ? , c_delivery_cnt = c_delivery_cnt + 1 WHERE c_id = ? AND c_d_id = ? AND c_w_id = ?"
112112
tx.execute_drain(
113113
&statements[6],
114114
&[
115-
("?1", DataValue::Decimal(ol_total)),
116-
("?2", DataValue::Int32(c_id)),
117-
("?3", DataValue::Int8(d_id as i8)),
118-
("?4", DataValue::Int16(args.w_id as i16)),
115+
("$1", DataValue::Decimal(ol_total)),
116+
("$2", DataValue::Int32(c_id)),
117+
("$3", DataValue::Int8(d_id as i8)),
118+
("$4", DataValue::Int16(args.w_id as i16)),
119119
],
120120
)?;
121121
}

0 commit comments

Comments
 (0)