@@ -13,6 +13,7 @@ import (
1313 "testing"
1414 "time"
1515
16+ "github.com/golang-sql/civil"
1617 "github.com/stretchr/testify/assert"
1718)
1819
@@ -29,6 +30,9 @@ func TestBulkcopyWithInvalidNullableType(t *testing.T) {
2930 "test_nullint16" ,
3031 "test_nulltime" ,
3132 "test_nulluniqueidentifier" ,
33+ "test_nulldate" ,
34+ "test_nulldatetime" ,
35+ "test_nullciviltime" ,
3236 }
3337 values := []interface {}{
3438 sql.NullFloat64 {Valid : false },
@@ -40,6 +44,9 @@ func TestBulkcopyWithInvalidNullableType(t *testing.T) {
4044 sql.NullInt16 {Valid : false },
4145 sql.NullTime {Valid : false },
4246 NullUniqueIdentifier {Valid : false },
47+ NullDate {Valid : false },
48+ NullDateTime {Valid : false },
49+ NullTime {Valid : false },
4350 }
4451
4552 pool , logger := open (t )
@@ -176,6 +183,9 @@ func testBulkcopy(t *testing.T, guidConversion bool) {
176183 {"test_nullint32" , sql.NullInt32 {2147483647 , true }, 2147483647 },
177184 {"test_nullint16" , sql.NullInt16 {32767 , true }, 32767 },
178185 {"test_nulltime" , sql.NullTime {time .Date (2010 , 11 , 12 , 13 , 14 , 15 , 120000000 , time .UTC ), true }, time .Date (2010 , 11 , 12 , 13 , 14 , 15 , 120000000 , time .UTC )},
186+ {"test_nulldate" , NullDate {civil.Date {Year : 2010 , Month : 11 , Day : 12 }, true }, time .Date (2010 , 11 , 12 , 0 , 0 , 0 , 0 , time .UTC )},
187+ {"test_nulldatetime" , NullDateTime {civil.DateTime {Date : civil.Date {Year : 2010 , Month : 11 , Day : 12 }, Time : civil.Time {Hour : 13 , Minute : 14 , Second : 15 , Nanosecond : 120000000 }}, true }, time .Date (2010 , 11 , 12 , 13 , 14 , 15 , 120000000 , time .UTC )},
188+ {"test_nullciviltime" , NullTime {civil.Time {Hour : 13 , Minute : 14 , Second : 15 , Nanosecond : 123000000 }, true }, time .Date (1 , 1 , 1 , 13 , 14 , 15 , 123000000 , time .UTC )},
179189 {"test_datetimen_midnight" , time .Date (2025 , 1 , 1 , 23 , 59 , 59 , 998_350_000 , time .UTC ), time .Date (2025 , 1 , 2 , 0 , 0 , 0 , 0 , time .UTC )},
180190 // {"test_smallmoney", 1234.56, nil},
181191 // {"test_money", 1234.56, nil},
@@ -351,6 +361,9 @@ func setupNullableTypeTable(ctx context.Context, t *testing.T, conn *sql.Conn, t
351361 [test_nullint16] [smallint] NULL,
352362 [test_nulltime] [datetime] NULL,
353363 [test_nulluniqueidentifier] [uniqueidentifier] NULL,
364+ [test_nulldate] [date] NULL,
365+ [test_nulldatetime] [datetime2] NULL,
366+ [test_nullciviltime] [time] NULL,
354367 CONSTRAINT [PK_` + tableName + `_id] PRIMARY KEY CLUSTERED
355368(
356369 [id] ASC
@@ -438,6 +451,9 @@ func setupTable(ctx context.Context, t *testing.T, conn *sql.Conn, tableName str
438451 [test_nullint32] [int] NULL,
439452 [test_nullint16] [smallint] NULL,
440453 [test_nulltime] [datetime] NULL,
454+ [test_nulldate] [date] NULL,
455+ [test_nulldatetime] [datetime2] NULL,
456+ [test_nullciviltime] [time] NULL,
441457 [test_datetimen_midnight] [datetime] NULL,
442458 CONSTRAINT [PK_` + tableName + `_id] PRIMARY KEY CLUSTERED
443459(
0 commit comments