diff --git a/internal/testutils/test_utils.go b/internal/testutils/test_utils.go
index c996077..97f90d6 100644
--- a/internal/testutils/test_utils.go
+++ b/internal/testutils/test_utils.go
@@ -292,11 +292,6 @@ func printDiff(actual, expected interface{}, options ...cmp.Option) {
fmt.Println(expected)
}
-// PtrOf returns the address of any given parameter
-func PtrOf[T any](value T) *T {
- return &value
-}
-
// UUIDPtr returns address of uuid.UUID
func UUIDPtr(u string) *uuid.UUID {
newUUID := uuid.MustParse(u)
diff --git a/internal/utils/ptr/ptr.go b/internal/utils/ptr/ptr.go
new file mode 100644
index 0000000..26f2688
--- /dev/null
+++ b/internal/utils/ptr/ptr.go
@@ -0,0 +1,6 @@
+package ptr
+
+// Of returns the address of any given parameter
+func Of[T any](value T) *T {
+ return &value
+}
diff --git a/tests/mysql/alltypes_test.go b/tests/mysql/alltypes_test.go
index b3f6a55..d5702bd 100644
--- a/tests/mysql/alltypes_test.go
+++ b/tests/mysql/alltypes_test.go
@@ -1,6 +1,7 @@
package mysql
import (
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
"github.com/shopspring/decimal"
"github.com/stretchr/testify/require"
"strings"
@@ -1067,7 +1068,7 @@ func TestAllTypesInsertOnDuplicateKeyUpdate(t *testing.T) {
var toInsert = model.AllTypes{
Boolean: false,
- BooleanPtr: testutils.PtrOf(true),
+ BooleanPtr: ptr.Of(true),
TinyInt: 1,
UTinyInt: 2,
SmallInt: 3,
@@ -1078,53 +1079,53 @@ var toInsert = model.AllTypes{
UInteger: 8,
BigInt: 9,
UBigInt: 1122334455,
- TinyIntPtr: testutils.PtrOf(int8(11)),
- UTinyIntPtr: testutils.PtrOf(uint8(22)),
- SmallIntPtr: testutils.PtrOf(int16(33)),
- USmallIntPtr: testutils.PtrOf(uint16(44)),
- MediumIntPtr: testutils.PtrOf(int32(55)),
- UMediumIntPtr: testutils.PtrOf(uint32(66)),
- IntegerPtr: testutils.PtrOf(int32(77)),
- UIntegerPtr: testutils.PtrOf(uint32(88)),
- BigIntPtr: testutils.PtrOf(int64(99)),
- UBigIntPtr: testutils.PtrOf(uint64(111)),
+ TinyIntPtr: ptr.Of(int8(11)),
+ UTinyIntPtr: ptr.Of(uint8(22)),
+ SmallIntPtr: ptr.Of(int16(33)),
+ USmallIntPtr: ptr.Of(uint16(44)),
+ MediumIntPtr: ptr.Of(int32(55)),
+ UMediumIntPtr: ptr.Of(uint32(66)),
+ IntegerPtr: ptr.Of(int32(77)),
+ UIntegerPtr: ptr.Of(uint32(88)),
+ BigIntPtr: ptr.Of(int64(99)),
+ UBigIntPtr: ptr.Of(uint64(111)),
Decimal: 11.22,
- DecimalPtr: testutils.PtrOf(33.44),
+ DecimalPtr: ptr.Of(33.44),
Numeric: 55.66,
- NumericPtr: testutils.PtrOf(77.88),
+ NumericPtr: ptr.Of(77.88),
Float: 99.00,
- FloatPtr: testutils.PtrOf(11.22),
+ FloatPtr: ptr.Of(11.22),
Double: 33.44,
- DoublePtr: testutils.PtrOf(55.66),
+ DoublePtr: ptr.Of(55.66),
Real: 77.88,
- RealPtr: testutils.PtrOf(99.00),
+ RealPtr: ptr.Of(99.00),
Bit: "1",
- BitPtr: testutils.PtrOf("0"),
+ BitPtr: ptr.Of("0"),
Time: time.Date(1, 1, 1, 10, 11, 12, 100, &time.Location{}),
- TimePtr: testutils.PtrOf(time.Date(1, 1, 1, 10, 11, 12, 100, time.UTC)),
+ TimePtr: ptr.Of(time.Date(1, 1, 1, 10, 11, 12, 100, time.UTC)),
Date: time.Now(),
- DatePtr: testutils.PtrOf(time.Now()),
+ DatePtr: ptr.Of(time.Now()),
DateTime: time.Now(),
- DateTimePtr: testutils.PtrOf(time.Now()),
+ DateTimePtr: ptr.Of(time.Now()),
Timestamp: time.Now(),
//TimestampPtr: testutils.TimePtr(time.Now()), // TODO: build fails for MariaDB
Year: 2000,
- YearPtr: testutils.PtrOf(int16(2001)),
+ YearPtr: ptr.Of(int16(2001)),
Char: "abcd",
- CharPtr: testutils.PtrOf("absd"),
+ CharPtr: ptr.Of("absd"),
VarChar: "abcd",
- VarCharPtr: testutils.PtrOf("absd"),
+ VarCharPtr: ptr.Of("absd"),
Binary: []byte("1010"),
- BinaryPtr: testutils.PtrOf([]byte("100001")),
+ BinaryPtr: ptr.Of([]byte("100001")),
VarBinary: []byte("1010"),
- VarBinaryPtr: testutils.PtrOf([]byte("100001")),
+ VarBinaryPtr: ptr.Of([]byte("100001")),
Blob: []byte("large file"),
- BlobPtr: testutils.PtrOf([]byte("very large file")),
+ BlobPtr: ptr.Of([]byte("very large file")),
Text: "some text",
- TextPtr: testutils.PtrOf("text"),
+ TextPtr: ptr.Of("text"),
Enum: model.AllTypesEnum_Value1,
JSON: "{}",
- JSONPtr: testutils.PtrOf(`{"a": 1}`),
+ JSONPtr: ptr.Of(`{"a": 1}`),
}
var allTypesJson = `
@@ -1358,17 +1359,17 @@ func TestExactDecimals(t *testing.T) {
Floats: model.Floats{
// overwritten by wrapped(floats) scope
Numeric: 0.1,
- NumericPtr: testutils.PtrOf(0.1),
+ NumericPtr: ptr.Of(0.1),
Decimal: 0.1,
- DecimalPtr: testutils.PtrOf(0.1),
+ DecimalPtr: ptr.Of(0.1),
// not overwritten
Float: 0.2,
- FloatPtr: testutils.PtrOf(0.22),
+ FloatPtr: ptr.Of(0.22),
Double: 0.3,
- DoublePtr: testutils.PtrOf(0.33),
+ DoublePtr: ptr.Of(0.33),
Real: 0.4,
- RealPtr: testutils.PtrOf(0.44),
+ RealPtr: ptr.Of(0.44),
},
Numeric: decimal.RequireFromString("12.35"),
NumericPtr: decimal.RequireFromString("56.79"),
diff --git a/tests/mysql/insert_test.go b/tests/mysql/insert_test.go
index f0655f2..8874456 100644
--- a/tests/mysql/insert_test.go
+++ b/tests/mysql/insert_test.go
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"github.com/go-jet/jet/v2/internal/testutils"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
. "github.com/go-jet/jet/v2/mysql"
"github.com/go-jet/jet/v2/tests/.gentestdata/mysql/test_sample/model"
. "github.com/go-jet/jet/v2/tests/.gentestdata/mysql/test_sample/table"
@@ -301,7 +302,7 @@ func TestInsertOnDuplicateKeyUpdateNEW(t *testing.T) {
ID: randId,
URL: "https://www.yahoo.com",
Name: "Yahoo",
- Description: testutils.PtrOf("web portal and search engine"),
+ Description: ptr.Of("web portal and search engine"),
},
}).AS_NEW().
ON_DUPLICATE_KEY_UPDATE(
@@ -338,7 +339,7 @@ ON DUPLICATE KEY UPDATE id = (link.id + ?),
ID: randId + 11,
URL: "https://www.yahoo.com",
Name: "Yahoo",
- Description: testutils.PtrOf("web portal and search engine"),
+ Description: ptr.Of("web portal and search engine"),
})
})
}
diff --git a/tests/postgres/alltypes_test.go b/tests/postgres/alltypes_test.go
index 7894293..2f1be14 100644
--- a/tests/postgres/alltypes_test.go
+++ b/tests/postgres/alltypes_test.go
@@ -2,6 +2,7 @@ package postgres
import (
"database/sql"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
"testing"
"time"
@@ -1305,32 +1306,32 @@ RETURNING all_types.json AS "all_types.json";
var moodSad = model.Mood_Sad
var allTypesRow0 = model.AllTypes{
- SmallIntPtr: testutils.PtrOf(int16(14)),
+ SmallIntPtr: ptr.Of(int16(14)),
SmallInt: 14,
- IntegerPtr: testutils.PtrOf(int32(300)),
+ IntegerPtr: ptr.Of(int32(300)),
Integer: 300,
- BigIntPtr: testutils.PtrOf(int64(50000)),
+ BigIntPtr: ptr.Of(int64(50000)),
BigInt: 5000,
- DecimalPtr: testutils.PtrOf(1.11),
+ DecimalPtr: ptr.Of(1.11),
Decimal: 1.11,
- NumericPtr: testutils.PtrOf(2.22),
+ NumericPtr: ptr.Of(2.22),
Numeric: 2.22,
- RealPtr: testutils.PtrOf(float32(5.55)),
+ RealPtr: ptr.Of(float32(5.55)),
Real: 5.55,
- DoublePrecisionPtr: testutils.PtrOf(11111111.22),
+ DoublePrecisionPtr: ptr.Of(11111111.22),
DoublePrecision: 11111111.22,
Smallserial: 1,
Serial: 1,
Bigserial: 1,
//MoneyPtr: nil,
//Money:
- VarCharPtr: testutils.PtrOf("ABBA"),
+ VarCharPtr: ptr.Of("ABBA"),
VarChar: "ABBA",
- CharPtr: testutils.PtrOf("JOHN "),
+ CharPtr: ptr.Of("JOHN "),
Char: "JOHN ",
- TextPtr: testutils.PtrOf("Some text"),
+ TextPtr: ptr.Of("Some text"),
Text: "Some text",
- ByteaPtr: testutils.PtrOf([]byte("bytea")),
+ ByteaPtr: ptr.Of([]byte("bytea")),
Bytea: []byte("bytea"),
TimestampzPtr: testutils.TimestampWithTimeZone("1999-01-08 13:05:06 +0100 CET", 0),
Timestampz: *testutils.TimestampWithTimeZone("1999-01-08 13:05:06 +0100 CET", 0),
@@ -1342,31 +1343,31 @@ var allTypesRow0 = model.AllTypes{
Timez: *testutils.TimeWithTimeZone("04:05:06 -0800"),
TimePtr: testutils.TimeWithoutTimeZone("04:05:06"),
Time: *testutils.TimeWithoutTimeZone("04:05:06"),
- IntervalPtr: testutils.PtrOf("3 days 04:05:06"),
+ IntervalPtr: ptr.Of("3 days 04:05:06"),
Interval: "3 days 04:05:06",
- BooleanPtr: testutils.PtrOf(true),
+ BooleanPtr: ptr.Of(true),
Boolean: false,
- PointPtr: testutils.PtrOf("(2,3)"),
- BitPtr: testutils.PtrOf("101"),
+ PointPtr: ptr.Of("(2,3)"),
+ BitPtr: ptr.Of("101"),
Bit: "101",
- BitVaryingPtr: testutils.PtrOf("101111"),
+ BitVaryingPtr: ptr.Of("101111"),
BitVarying: "101111",
- TsvectorPtr: testutils.PtrOf("'supernova':1"),
+ TsvectorPtr: ptr.Of("'supernova':1"),
Tsvector: "'supernova':1",
UUIDPtr: testutils.UUIDPtr("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
UUID: uuid.MustParse("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
- XMLPtr: testutils.PtrOf("abc"),
+ XMLPtr: ptr.Of("abc"),
XML: "abc",
- JSONPtr: testutils.PtrOf(`{"a": 1, "b": 3}`),
+ JSONPtr: ptr.Of(`{"a": 1, "b": 3}`),
JSON: `{"a": 1, "b": 3}`,
- JsonbPtr: testutils.PtrOf(`{"a": 1, "b": 3}`),
+ JsonbPtr: ptr.Of(`{"a": 1, "b": 3}`),
Jsonb: `{"a": 1, "b": 3}`,
- IntegerArrayPtr: testutils.PtrOf("{1,2,3}"),
+ IntegerArrayPtr: ptr.Of("{1,2,3}"),
IntegerArray: "{1,2,3}",
- TextArrayPtr: testutils.PtrOf("{breakfast,consulting}"),
+ TextArrayPtr: ptr.Of("{breakfast,consulting}"),
TextArray: "{breakfast,consulting}",
JsonbArray: `{"{\"a\": 1, \"b\": 2}","{\"a\": 3, \"b\": 4}"}`,
- TextMultiDimArrayPtr: testutils.PtrOf("{{meeting,lunch},{training,presentation}}"),
+ TextMultiDimArrayPtr: ptr.Of("{{meeting,lunch},{training,presentation}}"),
TextMultiDimArray: "{{meeting,lunch},{training,presentation}}",
MoodPtr: &moodSad,
Mood: model.Mood_Happy,
diff --git a/tests/postgres/chinook_db_test.go b/tests/postgres/chinook_db_test.go
index 7c7f957..33507e0 100644
--- a/tests/postgres/chinook_db_test.go
+++ b/tests/postgres/chinook_db_test.go
@@ -3,6 +3,7 @@ package postgres
import (
"context"
"github.com/go-jet/jet/v2/internal/testutils"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
. "github.com/go-jet/jet/v2/postgres"
"github.com/go-jet/jet/v2/tests/.gentestdata/jetdb/chinook/model"
. "github.com/go-jet/jet/v2/tests/.gentestdata/jetdb/chinook/table"
@@ -455,7 +456,7 @@ FROM (
require.Len(t, dest, 275)
require.Equal(t, dest[0].Artist1.Artist, model.Artist{
ArtistId: 1,
- Name: testutils.PtrOf("AC/DC"),
+ Name: ptr.Of("AC/DC"),
})
require.Equal(t, dest[0].Artist1.CustomColumn1, "custom_column_1")
require.Equal(t, dest[0].Artist1.CustomColumn2, "custom_column_2")
diff --git a/tests/postgres/sample_test.go b/tests/postgres/sample_test.go
index 8d12d0c..a1d4c2d 100644
--- a/tests/postgres/sample_test.go
+++ b/tests/postgres/sample_test.go
@@ -2,6 +2,7 @@ package postgres
import (
"database/sql"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
"github.com/google/uuid"
"testing"
@@ -63,15 +64,15 @@ func TestExactDecimals(t *testing.T) {
Floats: model.Floats{
// overwritten by wrapped(floats) scope
Numeric: 0.1,
- NumericPtr: testutils.PtrOf(0.1),
+ NumericPtr: ptr.Of(0.1),
Decimal: 0.1,
- DecimalPtr: testutils.PtrOf(0.1),
+ DecimalPtr: ptr.Of(0.1),
// not overwritten
Real: 0.4,
- RealPtr: testutils.PtrOf(float32(0.44)),
+ RealPtr: ptr.Of(float32(0.44)),
Double: 0.3,
- DoublePtr: testutils.PtrOf(0.33),
+ DoublePtr: ptr.Of(0.33),
},
Numeric: decimal.RequireFromString("0.1234567890123456789"),
NumericPtr: decimal.RequireFromString("1.1111111111111111111"),
@@ -378,7 +379,7 @@ ORDER BY employee.employee_id;
FirstName: "Salley",
LastName: "Lester",
EmploymentDate: testutils.TimestampWithTimeZone("1999-01-08 04:05:06 +0100 CET", 1),
- ManagerID: testutils.PtrOf(int32(3)),
+ ManagerID: ptr.Of(int32(3)),
})
}
@@ -420,7 +421,7 @@ FROM test_sample."WEIRD NAMES TABLE";
WeirdColumnName5: "Doe",
WeirdColumnName6: "Doe",
WeirdColumnName7: "Doe",
- Weirdcolumnname8: testutils.PtrOf("Doe"),
+ Weirdcolumnname8: ptr.Of("Doe"),
WeirdColName9: "Doe",
WeirdColuName10: "Doe",
WeirdColuName11: "Doe",
@@ -518,7 +519,7 @@ func TestMutableColumnsExcludeGeneratedColumn(t *testing.T) {
).MODEL(
model.People{
PeopleName: "Dario",
- PeopleHeightCm: testutils.PtrOf(120.0),
+ PeopleHeightCm: ptr.Of(120.0),
},
).RETURNING(
People.MutableColumns,
diff --git a/tests/postgres/scan_test.go b/tests/postgres/scan_test.go
index b71f49a..321fc38 100644
--- a/tests/postgres/scan_test.go
+++ b/tests/postgres/scan_test.go
@@ -2,6 +2,7 @@ package postgres
import (
"context"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
"github.com/volatiletech/null/v8"
"testing"
"time"
@@ -93,7 +94,7 @@ func TestScanToValidDestination(t *testing.T) {
err := oneInventoryQuery.Query(db, &dest)
require.NoError(t, err)
- require.Equal(t, dest[0], testutils.PtrOf(int32(1)))
+ require.Equal(t, dest[0], ptr.Of(int32(1)))
})
t.Run("NULL to integer", func(t *testing.T) {
@@ -530,10 +531,10 @@ func TestScanToSlice(t *testing.T) {
require.NoError(t, err)
require.Equal(t, len(dest), 2)
testutils.AssertDeepEqual(t, dest[0].Film, film1)
- testutils.AssertDeepEqual(t, dest[0].IDs, []*int32{testutils.PtrOf(int32(1)), testutils.PtrOf(int32(2)), testutils.PtrOf(int32(3)), testutils.PtrOf(int32(4)),
- testutils.PtrOf(int32(5)), testutils.PtrOf(int32(6)), testutils.PtrOf(int32(7)), testutils.PtrOf(int32(8))})
+ testutils.AssertDeepEqual(t, dest[0].IDs, []*int32{ptr.Of(int32(1)), ptr.Of(int32(2)), ptr.Of(int32(3)), ptr.Of(int32(4)),
+ ptr.Of(int32(5)), ptr.Of(int32(6)), ptr.Of(int32(7)), ptr.Of(int32(8))})
testutils.AssertDeepEqual(t, dest[1].Film, film2)
- testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{testutils.PtrOf(int32(9)), testutils.PtrOf(int32(10))})
+ testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{ptr.Of(int32(9)), ptr.Of(int32(10))})
})
t.Run("complex struct 1", func(t *testing.T) {
@@ -1076,10 +1077,10 @@ VALUES (1234, 0, 'Joe', '', NULL, 1, TRUE, '2020-02-02 10:00:00Z', NULL, 1);
var address256 = model.Address{
AddressID: 256,
Address: "1497 Yuzhou Drive",
- Address2: testutils.PtrOf(""),
+ Address2: ptr.Of(""),
District: "England",
CityID: 312,
- PostalCode: testutils.PtrOf("3433"),
+ PostalCode: ptr.Of("3433"),
Phone: "246810237916",
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
}
@@ -1087,10 +1088,10 @@ var address256 = model.Address{
var addres517 = model.Address{
AddressID: 517,
Address: "548 Uruapan Street",
- Address2: testutils.PtrOf(""),
+ Address2: ptr.Of(""),
District: "Ontario",
CityID: 312,
- PostalCode: testutils.PtrOf("35653"),
+ PostalCode: ptr.Of("35653"),
Phone: "879347453467",
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
}
@@ -1100,12 +1101,12 @@ var customer256 = model.Customer{
StoreID: 2,
FirstName: "Mattie",
LastName: "Hoffman",
- Email: testutils.PtrOf("mattie.hoffman@sakilacustomer.org"),
+ Email: ptr.Of("mattie.hoffman@sakilacustomer.org"),
AddressID: 256,
Activebool: true,
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 0),
- Active: testutils.PtrOf(int32(1)),
+ Active: ptr.Of(int32(1)),
}
var customer512 = model.Customer{
@@ -1113,12 +1114,12 @@ var customer512 = model.Customer{
StoreID: 1,
FirstName: "Cecil",
LastName: "Vines",
- Email: testutils.PtrOf("cecil.vines@sakilacustomer.org"),
+ Email: ptr.Of("cecil.vines@sakilacustomer.org"),
AddressID: 517,
Activebool: true,
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 0),
- Active: testutils.PtrOf(int32(1)),
+ Active: ptr.Of(int32(1)),
}
var countryUk = model.Country{
@@ -1151,32 +1152,32 @@ var inventory2 = model.Inventory{
var film1 = model.Film{
FilmID: 1,
Title: "Academy Dinosaur",
- Description: testutils.PtrOf("A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies"),
- ReleaseYear: testutils.PtrOf(int32(2006)),
+ Description: ptr.Of("A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies"),
+ ReleaseYear: ptr.Of(int32(2006)),
LanguageID: 1,
RentalDuration: 6,
RentalRate: 0.99,
- Length: testutils.PtrOf(int16(86)),
+ Length: ptr.Of(int16(86)),
ReplacementCost: 20.99,
Rating: &pgRating,
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
- SpecialFeatures: testutils.PtrOf("{\"Deleted Scenes\",\"Behind the Scenes\"}"),
+ SpecialFeatures: ptr.Of("{\"Deleted Scenes\",\"Behind the Scenes\"}"),
Fulltext: "'academi':1 'battl':15 'canadian':20 'dinosaur':2 'drama':5 'epic':4 'feminist':8 'mad':11 'must':14 'rocki':21 'scientist':12 'teacher':17",
}
var film2 = model.Film{
FilmID: 2,
Title: "Ace Goldfinger",
- Description: testutils.PtrOf("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
- ReleaseYear: testutils.PtrOf(int32(2006)),
+ Description: ptr.Of("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
+ ReleaseYear: ptr.Of(int32(2006)),
LanguageID: 1,
RentalDuration: 3,
RentalRate: 4.99,
- Length: testutils.PtrOf(int16(48)),
+ Length: ptr.Of(int16(48)),
ReplacementCost: 12.99,
Rating: &gRating,
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
- SpecialFeatures: testutils.PtrOf(`{Trailers,"Deleted Scenes"}`),
+ SpecialFeatures: ptr.Of(`{Trailers,"Deleted Scenes"}`),
Fulltext: `'ace':1 'administr':9 'ancient':19 'astound':4 'car':17 'china':20 'databas':8 'epistl':5 'explor':12 'find':15 'goldfing':2 'must':14`,
}
diff --git a/tests/postgres/select_test.go b/tests/postgres/select_test.go
index 94bd68d..14dd627 100644
--- a/tests/postgres/select_test.go
+++ b/tests/postgres/select_test.go
@@ -3,6 +3,7 @@ package postgres
import (
"context"
"database/sql"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
"testing"
"time"
@@ -1828,16 +1829,16 @@ ORDER BY film.film_id ASC;
testutils.AssertDeepEqual(t, maxRentalRateFilms[0], model.Film{
FilmID: 2,
Title: "Ace Goldfinger",
- Description: testutils.PtrOf("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
- ReleaseYear: testutils.PtrOf(int32(2006)),
+ Description: ptr.Of("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
+ ReleaseYear: ptr.Of(int32(2006)),
LanguageID: 1,
RentalRate: 4.99,
- Length: testutils.PtrOf(int16(48)),
+ Length: ptr.Of(int16(48)),
ReplacementCost: 12.99,
Rating: &gRating,
RentalDuration: 3,
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
- SpecialFeatures: testutils.PtrOf("{Trailers,\"Deleted Scenes\"}"),
+ SpecialFeatures: ptr.Of("{Trailers,\"Deleted Scenes\"}"),
Fulltext: "'ace':1 'administr':9 'ancient':19 'astound':4 'car':17 'china':20 'databas':8 'epistl':5 'explor':12 'find':15 'goldfing':2 'must':14",
})
}
@@ -2286,11 +2287,11 @@ ORDER BY customer_payment_sum.amount_sum ASC;
FirstName: "Brian",
LastName: "Wyman",
AddressID: 323,
- Email: testutils.PtrOf("brian.wyman@sakilacustomer.org"),
+ Email: ptr.Of("brian.wyman@sakilacustomer.org"),
Activebool: true,
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
- Active: testutils.PtrOf(int32(1)),
+ Active: ptr.Of(int32(1)),
})
require.Equal(t, customersWithAmounts[0].AmountSum, 27.93)
@@ -3133,8 +3134,8 @@ func TestDynamicCondition(t *testing.T) {
Active *bool
}
- request.CustomerID = testutils.PtrOf(int64(1))
- request.Active = testutils.PtrOf(true)
+ request.CustomerID = ptr.Of(int64(1))
+ request.Active = ptr.Of(true)
// ...
@@ -3894,12 +3895,12 @@ var customer0 = model.Customer{
StoreID: 1,
FirstName: "Mary",
LastName: "Smith",
- Email: testutils.PtrOf("mary.smith@sakilacustomer.org"),
+ Email: ptr.Of("mary.smith@sakilacustomer.org"),
AddressID: 5,
Activebool: true,
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
- Active: testutils.PtrOf(int32(1)),
+ Active: ptr.Of(int32(1)),
}
var customer1 = model.Customer{
@@ -3907,12 +3908,12 @@ var customer1 = model.Customer{
StoreID: 1,
FirstName: "Patricia",
LastName: "Johnson",
- Email: testutils.PtrOf("patricia.johnson@sakilacustomer.org"),
+ Email: ptr.Of("patricia.johnson@sakilacustomer.org"),
AddressID: 6,
Activebool: true,
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
- Active: testutils.PtrOf(int32(1)),
+ Active: ptr.Of(int32(1)),
}
var lastCustomer = model.Customer{
@@ -3920,10 +3921,10 @@ var lastCustomer = model.Customer{
StoreID: 2,
FirstName: "Austin",
LastName: "Cintron",
- Email: testutils.PtrOf("austin.cintron@sakilacustomer.org"),
+ Email: ptr.Of("austin.cintron@sakilacustomer.org"),
AddressID: 605,
Activebool: true,
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 3),
- Active: testutils.PtrOf(int32(1)),
+ Active: ptr.Of(int32(1)),
}
diff --git a/tests/sqlite/alltypes_test.go b/tests/sqlite/alltypes_test.go
index 63d1835..41e5cf7 100644
--- a/tests/sqlite/alltypes_test.go
+++ b/tests/sqlite/alltypes_test.go
@@ -2,6 +2,7 @@ package sqlite
import (
"github.com/go-jet/jet/v2/internal/testutils"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
. "github.com/go-jet/jet/v2/sqlite"
"github.com/go-jet/jet/v2/tests/.gentestdata/sqlite/test_sample/model"
. "github.com/go-jet/jet/v2/tests/.gentestdata/sqlite/test_sample/table"
@@ -153,43 +154,43 @@ func TestAllTypesInsert(t *testing.T) {
var toInsert = model.AllTypes{
Boolean: false,
- BooleanPtr: testutils.PtrOf(true),
+ BooleanPtr: ptr.Of(true),
TinyInt: 1,
SmallInt: 3,
MediumInt: 5,
Integer: 7,
BigInt: 9,
- TinyIntPtr: testutils.PtrOf(int8(11)),
- SmallIntPtr: testutils.PtrOf(int16(33)),
- MediumIntPtr: testutils.PtrOf(int32(55)),
- IntegerPtr: testutils.PtrOf(int32(77)),
- BigIntPtr: testutils.PtrOf(int64(99)),
+ TinyIntPtr: ptr.Of(int8(11)),
+ SmallIntPtr: ptr.Of(int16(33)),
+ MediumIntPtr: ptr.Of(int32(55)),
+ IntegerPtr: ptr.Of(int32(77)),
+ BigIntPtr: ptr.Of(int64(99)),
Decimal: 11.22,
- DecimalPtr: testutils.PtrOf(33.44),
+ DecimalPtr: ptr.Of(33.44),
Numeric: 55.66,
- NumericPtr: testutils.PtrOf(77.88),
+ NumericPtr: ptr.Of(77.88),
Float: 99.00,
- FloatPtr: testutils.PtrOf(11.22),
+ FloatPtr: ptr.Of(11.22),
Double: 33.44,
- DoublePtr: testutils.PtrOf(55.66),
+ DoublePtr: ptr.Of(55.66),
Real: 77.88,
- RealPtr: testutils.PtrOf(float32(99.00)),
+ RealPtr: ptr.Of(float32(99.00)),
Time: time.Date(1, 1, 1, 1, 1, 1, 10, time.UTC),
- TimePtr: testutils.PtrOf(time.Date(2, 2, 2, 2, 2, 2, 200, time.UTC)),
+ TimePtr: ptr.Of(time.Date(2, 2, 2, 2, 2, 2, 200, time.UTC)),
Date: time.Now(),
- DatePtr: testutils.PtrOf(time.Now()),
+ DatePtr: ptr.Of(time.Now()),
DateTime: time.Now(),
- DateTimePtr: testutils.PtrOf(time.Now()),
+ DateTimePtr: ptr.Of(time.Now()),
Timestamp: time.Now(),
- TimestampPtr: testutils.PtrOf(time.Now()),
+ TimestampPtr: ptr.Of(time.Now()),
Char: "abcd",
- CharPtr: testutils.PtrOf("absd"),
+ CharPtr: ptr.Of("absd"),
VarChar: "abcd",
- VarCharPtr: testutils.PtrOf("absd"),
+ VarCharPtr: ptr.Of("absd"),
Blob: []byte("large file"),
- BlobPtr: testutils.PtrOf([]byte("very large file")),
+ BlobPtr: ptr.Of([]byte("very large file")),
Text: "some text",
- TextPtr: testutils.PtrOf("text"),
+ TextPtr: ptr.Of("text"),
}
func TestUUID(t *testing.T) {
@@ -659,7 +660,7 @@ func TestExactDecimals(t *testing.T) {
// not overwritten
Numeric: "6.7",
- NumericPtr: testutils.PtrOf("7.7"),
+ NumericPtr: ptr.Of("7.7"),
},
Decimal: decimal.RequireFromString("91.23"),
DecimalPtr: decimal.RequireFromString("45.67"),
diff --git a/tests/sqlite/insert_test.go b/tests/sqlite/insert_test.go
index 5e9c7b2..dd31784 100644
--- a/tests/sqlite/insert_test.go
+++ b/tests/sqlite/insert_test.go
@@ -3,6 +3,7 @@ package sqlite
import (
"context"
"database/sql"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
"math/rand"
"testing"
@@ -49,7 +50,7 @@ VALUES (?, ?, ?, ?),
ID: 101,
URL: "http://www.google.com",
Name: "Google",
- Description: testutils.PtrOf("Search engine"),
+ Description: ptr.Of("Search engine"),
})
testutils.AssertDeepEqual(t, insertedLinks[2], model.Link{
ID: 102,
diff --git a/tests/sqlite/sample_test.go b/tests/sqlite/sample_test.go
index 7349d76..c306421 100644
--- a/tests/sqlite/sample_test.go
+++ b/tests/sqlite/sample_test.go
@@ -3,6 +3,7 @@ package sqlite
import (
"database/sql"
"github.com/go-jet/jet/v2/internal/testutils"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
"github.com/stretchr/testify/require"
"testing"
@@ -54,7 +55,7 @@ WHERE people.people_id = ?;
).MODEL(
model.People{
PeopleName: "Dario",
- PeopleHeightCm: testutils.PtrOf(190.0),
+ PeopleHeightCm: ptr.Of(190.0),
},
).RETURNING(
People.AllColumns,
diff --git a/tests/sqlite/select_test.go b/tests/sqlite/select_test.go
index da4fa71..baafa76 100644
--- a/tests/sqlite/select_test.go
+++ b/tests/sqlite/select_test.go
@@ -2,6 +2,7 @@ package sqlite
import (
"context"
+ "github.com/go-jet/jet/v2/internal/utils/ptr"
model2 "github.com/go-jet/jet/v2/tests/.gentestdata/sqlite/chinook/model"
"github.com/go-jet/jet/v2/tests/.gentestdata/sqlite/chinook/table"
"strings"
@@ -846,15 +847,15 @@ func TestSimpleView(t *testing.T) {
require.Equal(t, len(dest), 10)
require.Equal(t, dest[2], model.CustomerList{
- ID: testutils.PtrOf(int32(3)),
- Name: testutils.PtrOf("LINDA WILLIAMS"),
- Address: testutils.PtrOf("692 Joliet Street"),
- ZipCode: testutils.PtrOf("83579"),
- Phone: testutils.PtrOf(" "),
- City: testutils.PtrOf("Athenai"),
- Country: testutils.PtrOf("Greece"),
- Notes: testutils.PtrOf("active"),
- Sid: testutils.PtrOf(int32(1)),
+ ID: ptr.Of(int32(3)),
+ Name: ptr.Of("LINDA WILLIAMS"),
+ Address: ptr.Of("692 Joliet Street"),
+ ZipCode: ptr.Of("83579"),
+ Phone: ptr.Of(" "),
+ City: ptr.Of("Athenai"),
+ Country: ptr.Of("Greece"),
+ Notes: ptr.Of("active"),
+ Sid: ptr.Of(int32(1)),
})
}