github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/tests/integration/database_sql_ignore_placeholder_test.go (about)

     1  //go:build integration
     2  // +build integration
     3  
     4  package integration
     5  
     6  import (
     7  	"context"
     8  	"database/sql"
     9  	"testing"
    10  	"time"
    11  
    12  	"github.com/ydb-platform/ydb-go-sdk/v3"
    13  	"github.com/ydb-platform/ydb-go-sdk/v3/retry"
    14  )
    15  
    16  func TestDatabaseSqlDiscardColumn(t *testing.T) {
    17  	scope := newScope(t)
    18  	db := scope.SQLDriverWithFolder(
    19  		ydb.WithTablePathPrefix(scope.Folder()),
    20  		ydb.WithAutoDeclare(),
    21  		ydb.WithNumericArgs(),
    22  	)
    23  	dt := time.Date(2023, 3, 1, 16, 34, 18, 0, time.UTC)
    24  
    25  	var row *sql.Row
    26  	err := retry.Retry(scope.Ctx, func(ctx context.Context) (err error) {
    27  		row = db.QueryRowContext(ctx, `
    28  			SELECT 
    29  				$1 AS vInt,
    30  				$2 AS __discard_column_1,
    31  				$3 AS __discard_column_2,
    32  				$4 AS __discard_column_3 
    33  			`, 1, "2", 3.0, dt,
    34  		)
    35  		return row.Err()
    36  	})
    37  	scope.Require.NoError(err)
    38  
    39  	var resInt int
    40  	scope.Require.NoError(row.Scan(&resInt))
    41  
    42  	scope.Require.Equal(1, resInt)
    43  }