99
1010 "github.com/stretchr/testify/require"
1111
12+ "github.com/ydb-platform/ydb-go-sdk/v3/internal/params"
1213 "github.com/ydb-platform/ydb-go-sdk/v3/table"
1314 "github.com/ydb-platform/ydb-go-sdk/v3/table/types"
1415)
@@ -346,27 +347,27 @@ func named(name string, value interface{}) driver.NamedValue {
346347func TestYdbParam (t * testing.T ) {
347348 for _ , tt := range []struct {
348349 src interface {}
349- dst table. ParameterOption
350+ dst * params. Parameter
350351 err error
351352 }{
352353 {
353- src : table . ValueParam ("$a" , types .Int32Value (42 )),
354- dst : table . ValueParam ("$a" , types .Int32Value (42 )),
354+ src : params . Named ("$a" , types .Int32Value (42 )),
355+ dst : params . Named ("$a" , types .Int32Value (42 )),
355356 err : nil ,
356357 },
357358 {
358359 src : named ("a" , int (42 )),
359- dst : table . ValueParam ("$a" , types .Int32Value (42 )),
360+ dst : params . Named ("$a" , types .Int32Value (42 )),
360361 err : nil ,
361362 },
362363 {
363364 src : named ("$a" , int (42 )),
364- dst : table . ValueParam ("$a" , types .Int32Value (42 )),
365+ dst : params . Named ("$a" , types .Int32Value (42 )),
365366 err : nil ,
366367 },
367368 {
368369 src : named ("a" , uint (42 )),
369- dst : table . ValueParam ("$a" , types .Uint32Value (42 )),
370+ dst : params . Named ("$a" , types .Uint32Value (42 )),
370371 err : nil ,
371372 },
372373 {
@@ -389,50 +390,50 @@ func TestYdbParam(t *testing.T) {
389390func TestArgsToParams (t * testing.T ) {
390391 for _ , tt := range []struct {
391392 args []interface {}
392- params []table. ParameterOption
393+ params []* params. Parameter
393394 err error
394395 }{
395396 {
396397 args : []interface {}{},
397- params : []table. ParameterOption {},
398+ params : []* params. Parameter {},
398399 err : nil ,
399400 },
400401 {
401402 args : []interface {}{
402403 1 , uint64 (2 ), "3" ,
403404 },
404- params : []table. ParameterOption {
405- table . ValueParam ("$p0" , types .Int32Value (1 )),
406- table . ValueParam ("$p1" , types .Uint64Value (2 )),
407- table . ValueParam ("$p2" , types .TextValue ("3" )),
405+ params : []* params. Parameter {
406+ params . Named ("$p0" , types .Int32Value (1 )),
407+ params . Named ("$p1" , types .Uint64Value (2 )),
408+ params . Named ("$p2" , types .TextValue ("3" )),
408409 },
409410 err : nil ,
410411 },
411412 {
412413 args : []interface {}{
413414 table .NewQueryParameters (
414- table . ValueParam ("$p0" , types .Int32Value (1 )),
415- table . ValueParam ("$p1" , types .Uint64Value (2 )),
416- table . ValueParam ("$p2" , types .TextValue ("3" )),
415+ params . Named ("$p0" , types .Int32Value (1 )),
416+ params . Named ("$p1" , types .Uint64Value (2 )),
417+ params . Named ("$p2" , types .TextValue ("3" )),
417418 ),
418419 table .NewQueryParameters (
419- table . ValueParam ("$p0" , types .Int32Value (1 )),
420- table . ValueParam ("$p1" , types .Uint64Value (2 )),
421- table . ValueParam ("$p2" , types .TextValue ("3" )),
420+ params . Named ("$p0" , types .Int32Value (1 )),
421+ params . Named ("$p1" , types .Uint64Value (2 )),
422+ params . Named ("$p2" , types .TextValue ("3" )),
422423 ),
423424 },
424425 err : errMultipleQueryParameters ,
425426 },
426427 {
427428 args : []interface {}{
428- table . ValueParam ("$p0" , types .Int32Value (1 )),
429- table . ValueParam ("$p1" , types .Uint64Value (2 )),
430- table . ValueParam ("$p2" , types .TextValue ("3" )),
429+ params . Named ("$p0" , types .Int32Value (1 )),
430+ params . Named ("$p1" , types .Uint64Value (2 )),
431+ params . Named ("$p2" , types .TextValue ("3" )),
431432 },
432- params : []table. ParameterOption {
433- table . ValueParam ("$p0" , types .Int32Value (1 )),
434- table . ValueParam ("$p1" , types .Uint64Value (2 )),
435- table . ValueParam ("$p2" , types .TextValue ("3" )),
433+ params : []* params. Parameter {
434+ params . Named ("$p0" , types .Int32Value (1 )),
435+ params . Named ("$p1" , types .Uint64Value (2 )),
436+ params . Named ("$p2" , types .TextValue ("3" )),
436437 },
437438 err : nil ,
438439 },
@@ -442,10 +443,10 @@ func TestArgsToParams(t *testing.T) {
442443 sql .Named ("$p1" , types .Uint64Value (2 )),
443444 sql .Named ("$p2" , types .TextValue ("3" )),
444445 },
445- params : []table. ParameterOption {
446- table . ValueParam ("$p0" , types .Int32Value (1 )),
447- table . ValueParam ("$p1" , types .Uint64Value (2 )),
448- table . ValueParam ("$p2" , types .TextValue ("3" )),
446+ params : []* params. Parameter {
447+ params . Named ("$p0" , types .Int32Value (1 )),
448+ params . Named ("$p1" , types .Uint64Value (2 )),
449+ params . Named ("$p2" , types .TextValue ("3" )),
449450 },
450451 err : nil ,
451452 },
@@ -455,23 +456,23 @@ func TestArgsToParams(t *testing.T) {
455456 driver.NamedValue {Name : "$p1" , Value : types .Uint64Value (2 )},
456457 driver.NamedValue {Name : "$p2" , Value : types .TextValue ("3" )},
457458 },
458- params : []table. ParameterOption {
459- table . ValueParam ("$p0" , types .Int32Value (1 )),
460- table . ValueParam ("$p1" , types .Uint64Value (2 )),
461- table . ValueParam ("$p2" , types .TextValue ("3" )),
459+ params : []* params. Parameter {
460+ params . Named ("$p0" , types .Int32Value (1 )),
461+ params . Named ("$p1" , types .Uint64Value (2 )),
462+ params . Named ("$p2" , types .TextValue ("3" )),
462463 },
463464 err : nil ,
464465 },
465466 {
466467 args : []interface {}{
467- driver.NamedValue {Value : table . ValueParam ("$p0" , types .Int32Value (1 ))},
468- driver.NamedValue {Value : table . ValueParam ("$p1" , types .Uint64Value (2 ))},
469- driver.NamedValue {Value : table . ValueParam ("$p2" , types .TextValue ("3" ))},
468+ driver.NamedValue {Value : params . Named ("$p0" , types .Int32Value (1 ))},
469+ driver.NamedValue {Value : params . Named ("$p1" , types .Uint64Value (2 ))},
470+ driver.NamedValue {Value : params . Named ("$p2" , types .TextValue ("3" ))},
470471 },
471- params : []table. ParameterOption {
472- table . ValueParam ("$p0" , types .Int32Value (1 )),
473- table . ValueParam ("$p1" , types .Uint64Value (2 )),
474- table . ValueParam ("$p2" , types .TextValue ("3" )),
472+ params : []* params. Parameter {
473+ params . Named ("$p0" , types .Int32Value (1 )),
474+ params . Named ("$p1" , types .Uint64Value (2 )),
475+ params . Named ("$p2" , types .TextValue ("3" )),
475476 },
476477 err : nil ,
477478 },
@@ -481,37 +482,37 @@ func TestArgsToParams(t *testing.T) {
481482 driver.NamedValue {Value : uint64 (2 )},
482483 driver.NamedValue {Value : "3" },
483484 },
484- params : []table. ParameterOption {
485- table . ValueParam ("$p0" , types .Int32Value (1 )),
486- table . ValueParam ("$p1" , types .Uint64Value (2 )),
487- table . ValueParam ("$p2" , types .TextValue ("3" )),
485+ params : []* params. Parameter {
486+ params . Named ("$p0" , types .Int32Value (1 )),
487+ params . Named ("$p1" , types .Uint64Value (2 )),
488+ params . Named ("$p2" , types .TextValue ("3" )),
488489 },
489490 err : nil ,
490491 },
491492 {
492493 args : []interface {}{
493494 driver.NamedValue {Value : table .NewQueryParameters (
494- table . ValueParam ("$p0" , types .Int32Value (1 )),
495- table . ValueParam ("$p1" , types .Uint64Value (2 )),
496- table . ValueParam ("$p2" , types .TextValue ("3" )),
495+ params . Named ("$p0" , types .Int32Value (1 )),
496+ params . Named ("$p1" , types .Uint64Value (2 )),
497+ params . Named ("$p2" , types .TextValue ("3" )),
497498 )},
498499 },
499- params : []table. ParameterOption {
500- table . ValueParam ("$p0" , types .Int32Value (1 )),
501- table . ValueParam ("$p1" , types .Uint64Value (2 )),
502- table . ValueParam ("$p2" , types .TextValue ("3" )),
500+ params : []* params. Parameter {
501+ params . Named ("$p0" , types .Int32Value (1 )),
502+ params . Named ("$p1" , types .Uint64Value (2 )),
503+ params . Named ("$p2" , types .TextValue ("3" )),
503504 },
504505 err : nil ,
505506 },
506507 {
507508 args : []interface {}{
508509 driver.NamedValue {Value : table .NewQueryParameters (
509- table . ValueParam ("$p0" , types .Int32Value (1 )),
510- table . ValueParam ("$p1" , types .Uint64Value (2 )),
511- table . ValueParam ("$p2" , types .TextValue ("3" )),
510+ params . Named ("$p0" , types .Int32Value (1 )),
511+ params . Named ("$p1" , types .Uint64Value (2 )),
512+ params . Named ("$p2" , types .TextValue ("3" )),
512513 )},
513- driver.NamedValue {Value : table . ValueParam ("$p1" , types .Uint64Value (2 ))},
514- driver.NamedValue {Value : table . ValueParam ("$p2" , types .TextValue ("3" ))},
514+ driver.NamedValue {Value : params . Named ("$p1" , types .Uint64Value (2 ))},
515+ driver.NamedValue {Value : params . Named ("$p2" , types .TextValue ("3" ))},
515516 },
516517 err : errMultipleQueryParameters ,
517518 },
0 commit comments