@@ -43,8 +43,8 @@ use super::{
43
43
batch,
44
44
pool:: { CollectionCache , Conn } ,
45
45
support:: {
46
- as_list_value , as_type, as_value , bso_from_row, bso_to_insert_row, bso_to_update_row,
47
- ExecuteSqlRequestBuilder , StreamedResultSetAsync ,
46
+ as_type, bso_from_row, bso_to_insert_row, bso_to_update_row, ExecuteSqlRequestBuilder ,
47
+ StreamedResultSetAsync , ToSpannerValue ,
48
48
} ,
49
49
} ;
50
50
@@ -639,7 +639,11 @@ impl SpannerDb {
639
639
let mut params = HashMap :: new ( ) ;
640
640
params. insert (
641
641
"ids" . to_owned ( ) ,
642
- as_list_value ( uncached. into_iter ( ) . map ( |id| id. to_string ( ) ) ) ,
642
+ uncached
643
+ . into_iter ( )
644
+ . map ( |id| id. to_string ( ) )
645
+ . collect :: < Vec < String > > ( )
646
+ . to_spanner_value ( ) ,
643
647
) ;
644
648
let mut rs = self
645
649
. sql (
@@ -892,9 +896,12 @@ impl SpannerDb {
892
896
if self . quota . enabled {
893
897
sqlparams. insert (
894
898
"total_bytes" . to_owned ( ) ,
895
- as_value ( result[ 0 ] . take_string_value ( ) ) ,
899
+ result[ 0 ] . take_string_value ( ) . to_spanner_value ( ) ,
900
+ ) ;
901
+ sqlparams. insert (
902
+ "count" . to_owned ( ) ,
903
+ result[ 1 ] . take_string_value ( ) . to_spanner_value ( ) ,
896
904
) ;
897
- sqlparams. insert ( "count" . to_owned ( ) , as_value ( result[ 1 ] . take_string_value ( ) ) ) ;
898
905
sqltypes. insert (
899
906
"total_bytes" . to_owned ( ) ,
900
907
crate :: db:: spanner:: support:: as_type ( TypeCode :: INT64 ) ,
@@ -1175,7 +1182,7 @@ impl SpannerDb {
1175
1182
"fxa_kid" => user_id. fxa_kid,
1176
1183
"collection_id" => collection_id. to_string( ) ,
1177
1184
} ;
1178
- sqlparams. insert ( "ids" . to_owned ( ) , as_list_value ( params. ids . into_iter ( ) ) ) ;
1185
+ sqlparams. insert ( "ids" . to_owned ( ) , params. ids . to_spanner_value ( ) ) ;
1179
1186
self . sql (
1180
1187
"DELETE FROM bsos
1181
1188
WHERE fxa_uid = @fxa_uid
@@ -1220,7 +1227,7 @@ impl SpannerDb {
1220
1227
1221
1228
if !ids. is_empty ( ) {
1222
1229
query = format ! ( "{} AND bso_id IN UNNEST(@ids)" , query) ;
1223
- sqlparams. insert ( "ids" . to_owned ( ) , as_list_value ( ids. into_iter ( ) ) ) ;
1230
+ sqlparams. insert ( "ids" . to_owned ( ) , ids. to_spanner_value ( ) ) ;
1224
1231
}
1225
1232
1226
1233
// issue559: Dead code (timestamp always None)
@@ -1243,12 +1250,12 @@ impl SpannerDb {
1243
1250
*/
1244
1251
if let Some ( older) = older {
1245
1252
query = format ! ( "{} AND modified < @older" , query) ;
1246
- sqlparams. insert ( "older" . to_string ( ) , as_value ( older. as_rfc3339 ( ) ?) ) ;
1253
+ sqlparams. insert ( "older" . to_string ( ) , older. as_rfc3339 ( ) ?. to_spanner_value ( ) ) ;
1247
1254
sqltypes. insert ( "older" . to_string ( ) , as_type ( TypeCode :: TIMESTAMP ) ) ;
1248
1255
}
1249
1256
if let Some ( newer) = newer {
1250
1257
query = format ! ( "{} AND modified > @newer" , query) ;
1251
- sqlparams. insert ( "newer" . to_string ( ) , as_value ( newer. as_rfc3339 ( ) ?) ) ;
1258
+ sqlparams. insert ( "newer" . to_string ( ) , newer. as_rfc3339 ( ) ?. to_spanner_value ( ) ) ;
1252
1259
sqltypes. insert ( "newer" . to_string ( ) , as_type ( TypeCode :: TIMESTAMP ) ) ;
1253
1260
}
1254
1261
query = match sort {
@@ -1527,7 +1534,12 @@ impl SpannerDb {
1527
1534
} ;
1528
1535
sqlparams. insert (
1529
1536
"ids" . to_owned ( ) ,
1530
- as_list_value ( params. bsos . iter ( ) . map ( |pbso| pbso. id . clone ( ) ) ) ,
1537
+ params
1538
+ . bsos
1539
+ . iter ( )
1540
+ . map ( |pbso| pbso. id . clone ( ) )
1541
+ . collect :: < Vec < String > > ( )
1542
+ . to_spanner_value ( ) ,
1531
1543
) ;
1532
1544
let mut streaming = self
1533
1545
. sql (
@@ -1700,7 +1712,7 @@ impl SpannerDb {
1700
1712
"{}{}" ,
1701
1713
q,
1702
1714
if let Some ( sortindex) = bso. sortindex {
1703
- sqlparams. insert( "sortindex" . to_string( ) , as_value ( sortindex. to_string ( ) ) ) ;
1715
+ sqlparams. insert( "sortindex" . to_string( ) , sortindex. to_spanner_value ( ) ) ;
1704
1716
sqltypes. insert( "sortindex" . to_string( ) , as_type( TypeCode :: INT64 ) ) ;
1705
1717
1706
1718
format!( "{}{}" , comma( & q) , "sortindex = @sortindex" )
@@ -1714,7 +1726,7 @@ impl SpannerDb {
1714
1726
q,
1715
1727
if let Some ( ttl) = bso. ttl {
1716
1728
let expiry = timestamp. as_i64( ) + ( i64 :: from( ttl) * 1000 ) ;
1717
- sqlparams. insert( "expiry" . to_string( ) , as_value ( to_rfc3339( expiry) ?) ) ;
1729
+ sqlparams. insert( "expiry" . to_string( ) , to_rfc3339( expiry) ?. to_spanner_value ( ) ) ;
1718
1730
sqltypes. insert( "expiry" . to_string( ) , as_type( TypeCode :: TIMESTAMP ) ) ;
1719
1731
format!( "{}{}" , comma( & q) , "expiry = @expiry" )
1720
1732
} else {
@@ -1726,7 +1738,10 @@ impl SpannerDb {
1726
1738
"{}{}" ,
1727
1739
q,
1728
1740
if bso. payload. is_some( ) || bso. sortindex. is_some( ) {
1729
- sqlparams. insert( "modified" . to_string( ) , as_value( timestamp. as_rfc3339( ) ?) ) ;
1741
+ sqlparams. insert(
1742
+ "modified" . to_string( ) ,
1743
+ timestamp. as_rfc3339( ) ?. to_spanner_value( ) ,
1744
+ ) ;
1730
1745
sqltypes. insert( "modified" . to_string( ) , as_type( TypeCode :: TIMESTAMP ) ) ;
1731
1746
format!( "{}{}" , comma( & q) , "modified = @modified" )
1732
1747
} else {
@@ -1738,7 +1753,7 @@ impl SpannerDb {
1738
1753
"{}{}" ,
1739
1754
q,
1740
1755
if let Some ( payload) = bso. payload {
1741
- sqlparams. insert( "payload" . to_string( ) , as_value ( payload) ) ;
1756
+ sqlparams. insert( "payload" . to_string( ) , payload. to_spanner_value ( ) ) ;
1742
1757
format!( "{}{}" , comma( & q) , "payload = @payload" )
1743
1758
} else {
1744
1759
"" . to_string( )
@@ -1782,14 +1797,16 @@ impl SpannerDb {
1782
1797
use super :: support:: null_value;
1783
1798
let sortindex = bso
1784
1799
. sortindex
1785
- . map ( |sortindex| as_value ( sortindex. to_string ( ) ) )
1800
+ . map ( |sortindex| sortindex. to_spanner_value ( ) )
1786
1801
. unwrap_or_else ( null_value) ;
1787
1802
sqlparams. insert ( "sortindex" . to_string ( ) , sortindex) ;
1788
1803
sqltypes. insert ( "sortindex" . to_string ( ) , as_type ( TypeCode :: INT64 ) ) ;
1789
1804
}
1790
1805
sqlparams. insert (
1791
1806
"payload" . to_string ( ) ,
1792
- as_value ( bso. payload . unwrap_or_else ( || "" . to_owned ( ) ) ) ,
1807
+ bso. payload
1808
+ . unwrap_or_else ( || "" . to_owned ( ) )
1809
+ . to_spanner_value ( ) ,
1793
1810
) ;
1794
1811
let now_millis = timestamp. as_i64 ( ) ;
1795
1812
let ttl = bso. ttl . map_or ( i64:: from ( DEFAULT_BSO_TTL ) , |ttl| {
@@ -1801,10 +1818,13 @@ impl SpannerDb {
1801
1818
"!!!!! [test] INSERT expirystring:{:?}, timestamp:{:?}, ttl:{:?}" ,
1802
1819
& expirystring, timestamp, ttl
1803
1820
) ;
1804
- sqlparams. insert ( "expiry" . to_string ( ) , as_value ( expirystring) ) ;
1821
+ sqlparams. insert ( "expiry" . to_string ( ) , expirystring. to_spanner_value ( ) ) ;
1805
1822
sqltypes. insert ( "expiry" . to_string ( ) , as_type ( TypeCode :: TIMESTAMP ) ) ;
1806
1823
1807
- sqlparams. insert ( "modified" . to_string ( ) , as_value ( timestamp. as_rfc3339 ( ) ?) ) ;
1824
+ sqlparams. insert (
1825
+ "modified" . to_string ( ) ,
1826
+ timestamp. as_rfc3339 ( ) ?. to_spanner_value ( ) ,
1827
+ ) ;
1808
1828
sqltypes. insert ( "modified" . to_string ( ) , as_type ( TypeCode :: TIMESTAMP ) ) ;
1809
1829
sql. to_owned ( )
1810
1830
} ;
0 commit comments