diff --git a/examples/quick-start/quick-start.go b/examples/quick-start/quick-start.go
index e453f51..b4707f6 100644
--- a/examples/quick-start/quick-start.go
+++ b/examples/quick-start/quick-start.go
@@ -4,7 +4,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
- "io/ioutil"
+ "os"
_ "github.com/lib/pq"
@@ -90,7 +90,7 @@ func main() {
func jsonSave(path string, v interface{}) {
jsonText, _ := json.MarshalIndent(v, "", "\t")
- err := ioutil.WriteFile(path, jsonText, 0644)
+ err := os.WriteFile(path, jsonText, 0644)
panicOnError(err)
}
diff --git a/internal/testutils/test_utils.go b/internal/testutils/test_utils.go
index 22c0d9c..c996077 100644
--- a/internal/testutils/test_utils.go
+++ b/internal/testutils/test_utils.go
@@ -12,7 +12,6 @@ import (
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "io/ioutil"
"os"
"path/filepath"
"runtime"
@@ -109,7 +108,7 @@ func SaveJSONFile(v interface{}, testRelativePath string) {
jsonText, _ := json.MarshalIndent(v, "", "\t")
filePath := getFullPath(testRelativePath)
- err := ioutil.WriteFile(filePath, jsonText, 0644)
+ err := os.WriteFile(filePath, jsonText, 0644)
throw.OnError(err)
}
@@ -118,7 +117,7 @@ func SaveJSONFile(v interface{}, testRelativePath string) {
func AssertJSONFile(t *testing.T, data interface{}, testRelativePath string) {
filePath := getFullPath(testRelativePath)
- fileJSONData, err := ioutil.ReadFile(filePath)
+ fileJSONData, err := os.ReadFile(filePath)
require.NoError(t, err)
if runtime.GOOS == "windows" {
@@ -245,7 +244,7 @@ func AssertQueryPanicErr(t *testing.T, stmt jet.Statement, db qrm.DB, dest inter
// AssertFileContent check if file content at filePath contains expectedContent text.
func AssertFileContent(t *testing.T, filePath string, expectedContent string) {
- enumFileData, err := ioutil.ReadFile(filePath)
+ enumFileData, err := os.ReadFile(filePath)
require.NoError(t, err)
@@ -254,7 +253,7 @@ func AssertFileContent(t *testing.T, filePath string, expectedContent string) {
// AssertFileNamesEqual check if all filesInfos are contained in fileNames
func AssertFileNamesEqual(t *testing.T, dirPath string, fileNames ...string) {
- files, err := ioutil.ReadDir(dirPath)
+ files, err := os.ReadDir(dirPath)
require.NoError(t, err)
require.Equal(t, len(files), len(fileNames))
@@ -293,74 +292,9 @@ func printDiff(actual, expected interface{}, options ...cmp.Option) {
fmt.Println(expected)
}
-// BoolPtr returns address of bool parameter
-func BoolPtr(b bool) *bool {
- return &b
-}
-
-// Int8Ptr returns address of int8 parameter
-func Int8Ptr(i int8) *int8 {
- return &i
-}
-
-// UInt8Ptr returns address of uint8 parameter
-func UInt8Ptr(i uint8) *uint8 {
- return &i
-}
-
-// Int16Ptr returns address of int16 parameter
-func Int16Ptr(i int16) *int16 {
- return &i
-}
-
-// UInt16Ptr returns address of uint16 parameter
-func UInt16Ptr(i uint16) *uint16 {
- return &i
-}
-
-// Int32Ptr returns address of int32 parameter
-func Int32Ptr(i int32) *int32 {
- return &i
-}
-
-// UInt32Ptr returns address of uint32 parameter
-func UInt32Ptr(i uint32) *uint32 {
- return &i
-}
-
-// Int64Ptr returns address of int64 parameter
-func Int64Ptr(i int64) *int64 {
- return &i
-}
-
-// UInt64Ptr returns address of uint64 parameter
-func UInt64Ptr(i uint64) *uint64 {
- return &i
-}
-
-// StringPtr returns address of string parameter
-func StringPtr(s string) *string {
- return &s
-}
-
-// TimePtr returns address of time.Time parameter
-func TimePtr(t time.Time) *time.Time {
- return &t
-}
-
-// ByteArrayPtr returns address of []byte parameter
-func ByteArrayPtr(arr []byte) *[]byte {
- return &arr
-}
-
-// Float32Ptr returns address of float32 parameter
-func Float32Ptr(f float32) *float32 {
- return &f
-}
-
-// Float64Ptr returns address of float64 parameter
-func Float64Ptr(f float64) *float64 {
- return &f
+// PtrOf returns the address of any given parameter
+func PtrOf[T any](value T) *T {
+ return &value
}
// UUIDPtr returns address of uuid.UUID
diff --git a/tests/init/init.go b/tests/init/init.go
index 5a21ee7..10631f1 100644
--- a/tests/init/init.go
+++ b/tests/init/init.go
@@ -10,7 +10,6 @@ import (
"github.com/go-jet/jet/v2/generator/sqlite"
"github.com/go-jet/jet/v2/internal/utils/errfmt"
"github.com/go-jet/jet/v2/tests/internal/utils/repo"
- "io/ioutil"
"os"
"os/exec"
"strings"
@@ -184,7 +183,7 @@ func initPostgresDB(dbType string, connectionString string) error {
}
func execFile(db *sql.DB, sqlFilePath string) error {
- testSampleSql, err := ioutil.ReadFile(sqlFilePath)
+ testSampleSql, err := os.ReadFile(sqlFilePath)
if err != nil {
return fmt.Errorf("failed to read sql file - %s: %w", sqlFilePath, err)
}
diff --git a/tests/internal/utils/file/file.go b/tests/internal/utils/file/file.go
index 6d08d22..fea0634 100644
--- a/tests/internal/utils/file/file.go
+++ b/tests/internal/utils/file/file.go
@@ -2,7 +2,6 @@ package file
import (
"github.com/stretchr/testify/require"
- "io/ioutil"
"os"
"path"
"testing"
@@ -11,7 +10,7 @@ import (
// Exists expects file to exist on path constructed from pathElems and returns content of the file
func Exists(t *testing.T, pathElems ...string) (fileContent string) {
modelFilePath := path.Join(pathElems...)
- file, err := ioutil.ReadFile(modelFilePath)
+ file, err := os.ReadFile(modelFilePath)
require.Nil(t, err)
require.NotEmpty(t, file)
return string(file)
@@ -20,6 +19,6 @@ func Exists(t *testing.T, pathElems ...string) (fileContent string) {
// NotExists expects file not to exist on path constructed from pathElems
func NotExists(t *testing.T, pathElems ...string) {
modelFilePath := path.Join(pathElems...)
- _, err := ioutil.ReadFile(modelFilePath)
+ _, err := os.ReadFile(modelFilePath)
require.True(t, os.IsNotExist(err))
}
diff --git a/tests/mysql/alltypes_test.go b/tests/mysql/alltypes_test.go
index c90f774..b3f6a55 100644
--- a/tests/mysql/alltypes_test.go
+++ b/tests/mysql/alltypes_test.go
@@ -1067,7 +1067,7 @@ func TestAllTypesInsertOnDuplicateKeyUpdate(t *testing.T) {
var toInsert = model.AllTypes{
Boolean: false,
- BooleanPtr: testutils.BoolPtr(true),
+ BooleanPtr: testutils.PtrOf(true),
TinyInt: 1,
UTinyInt: 2,
SmallInt: 3,
@@ -1078,53 +1078,53 @@ var toInsert = model.AllTypes{
UInteger: 8,
BigInt: 9,
UBigInt: 1122334455,
- TinyIntPtr: testutils.Int8Ptr(11),
- UTinyIntPtr: testutils.UInt8Ptr(22),
- SmallIntPtr: testutils.Int16Ptr(33),
- USmallIntPtr: testutils.UInt16Ptr(44),
- MediumIntPtr: testutils.Int32Ptr(55),
- UMediumIntPtr: testutils.UInt32Ptr(66),
- IntegerPtr: testutils.Int32Ptr(77),
- UIntegerPtr: testutils.UInt32Ptr(88),
- BigIntPtr: testutils.Int64Ptr(99),
- UBigIntPtr: testutils.UInt64Ptr(111),
+ 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)),
Decimal: 11.22,
- DecimalPtr: testutils.Float64Ptr(33.44),
+ DecimalPtr: testutils.PtrOf(33.44),
Numeric: 55.66,
- NumericPtr: testutils.Float64Ptr(77.88),
+ NumericPtr: testutils.PtrOf(77.88),
Float: 99.00,
- FloatPtr: testutils.Float64Ptr(11.22),
+ FloatPtr: testutils.PtrOf(11.22),
Double: 33.44,
- DoublePtr: testutils.Float64Ptr(55.66),
+ DoublePtr: testutils.PtrOf(55.66),
Real: 77.88,
- RealPtr: testutils.Float64Ptr(99.00),
+ RealPtr: testutils.PtrOf(99.00),
Bit: "1",
- BitPtr: testutils.StringPtr("0"),
+ BitPtr: testutils.PtrOf("0"),
Time: time.Date(1, 1, 1, 10, 11, 12, 100, &time.Location{}),
- TimePtr: testutils.TimePtr(time.Date(1, 1, 1, 10, 11, 12, 100, time.UTC)),
+ TimePtr: testutils.PtrOf(time.Date(1, 1, 1, 10, 11, 12, 100, time.UTC)),
Date: time.Now(),
- DatePtr: testutils.TimePtr(time.Now()),
+ DatePtr: testutils.PtrOf(time.Now()),
DateTime: time.Now(),
- DateTimePtr: testutils.TimePtr(time.Now()),
+ DateTimePtr: testutils.PtrOf(time.Now()),
Timestamp: time.Now(),
//TimestampPtr: testutils.TimePtr(time.Now()), // TODO: build fails for MariaDB
Year: 2000,
- YearPtr: testutils.Int16Ptr(2001),
+ YearPtr: testutils.PtrOf(int16(2001)),
Char: "abcd",
- CharPtr: testutils.StringPtr("absd"),
+ CharPtr: testutils.PtrOf("absd"),
VarChar: "abcd",
- VarCharPtr: testutils.StringPtr("absd"),
+ VarCharPtr: testutils.PtrOf("absd"),
Binary: []byte("1010"),
- BinaryPtr: testutils.ByteArrayPtr([]byte("100001")),
+ BinaryPtr: testutils.PtrOf([]byte("100001")),
VarBinary: []byte("1010"),
- VarBinaryPtr: testutils.ByteArrayPtr([]byte("100001")),
+ VarBinaryPtr: testutils.PtrOf([]byte("100001")),
Blob: []byte("large file"),
- BlobPtr: testutils.ByteArrayPtr([]byte("very large file")),
+ BlobPtr: testutils.PtrOf([]byte("very large file")),
Text: "some text",
- TextPtr: testutils.StringPtr("text"),
+ TextPtr: testutils.PtrOf("text"),
Enum: model.AllTypesEnum_Value1,
JSON: "{}",
- JSONPtr: testutils.StringPtr(`{"a": 1}`),
+ JSONPtr: testutils.PtrOf(`{"a": 1}`),
}
var allTypesJson = `
@@ -1358,17 +1358,17 @@ func TestExactDecimals(t *testing.T) {
Floats: model.Floats{
// overwritten by wrapped(floats) scope
Numeric: 0.1,
- NumericPtr: testutils.Float64Ptr(0.1),
+ NumericPtr: testutils.PtrOf(0.1),
Decimal: 0.1,
- DecimalPtr: testutils.Float64Ptr(0.1),
+ DecimalPtr: testutils.PtrOf(0.1),
// not overwritten
Float: 0.2,
- FloatPtr: testutils.Float64Ptr(0.22),
+ FloatPtr: testutils.PtrOf(0.22),
Double: 0.3,
- DoublePtr: testutils.Float64Ptr(0.33),
+ DoublePtr: testutils.PtrOf(0.33),
Real: 0.4,
- RealPtr: testutils.Float64Ptr(0.44),
+ RealPtr: testutils.PtrOf(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 b05c91d..f0655f2 100644
--- a/tests/mysql/insert_test.go
+++ b/tests/mysql/insert_test.go
@@ -7,6 +7,7 @@ import (
. "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"
+
"github.com/stretchr/testify/require"
"math/rand"
"testing"
@@ -300,7 +301,7 @@ func TestInsertOnDuplicateKeyUpdateNEW(t *testing.T) {
ID: randId,
URL: "https://www.yahoo.com",
Name: "Yahoo",
- Description: testutils.StringPtr("web portal and search engine"),
+ Description: testutils.PtrOf("web portal and search engine"),
},
}).AS_NEW().
ON_DUPLICATE_KEY_UPDATE(
@@ -337,7 +338,7 @@ ON DUPLICATE KEY UPDATE id = (link.id + ?),
ID: randId + 11,
URL: "https://www.yahoo.com",
Name: "Yahoo",
- Description: testutils.StringPtr("web portal and search engine"),
+ Description: testutils.PtrOf("web portal and search engine"),
})
})
}
diff --git a/tests/postgres/alltypes_test.go b/tests/postgres/alltypes_test.go
index d41feee..7894293 100644
--- a/tests/postgres/alltypes_test.go
+++ b/tests/postgres/alltypes_test.go
@@ -1305,32 +1305,32 @@ RETURNING all_types.json AS "all_types.json";
var moodSad = model.Mood_Sad
var allTypesRow0 = model.AllTypes{
- SmallIntPtr: testutils.Int16Ptr(14),
+ SmallIntPtr: testutils.PtrOf(int16(14)),
SmallInt: 14,
- IntegerPtr: testutils.Int32Ptr(300),
+ IntegerPtr: testutils.PtrOf(int32(300)),
Integer: 300,
- BigIntPtr: testutils.Int64Ptr(50000),
+ BigIntPtr: testutils.PtrOf(int64(50000)),
BigInt: 5000,
- DecimalPtr: testutils.Float64Ptr(1.11),
+ DecimalPtr: testutils.PtrOf(1.11),
Decimal: 1.11,
- NumericPtr: testutils.Float64Ptr(2.22),
+ NumericPtr: testutils.PtrOf(2.22),
Numeric: 2.22,
- RealPtr: testutils.Float32Ptr(5.55),
+ RealPtr: testutils.PtrOf(float32(5.55)),
Real: 5.55,
- DoublePrecisionPtr: testutils.Float64Ptr(11111111.22),
+ DoublePrecisionPtr: testutils.PtrOf(11111111.22),
DoublePrecision: 11111111.22,
Smallserial: 1,
Serial: 1,
Bigserial: 1,
//MoneyPtr: nil,
//Money:
- VarCharPtr: testutils.StringPtr("ABBA"),
+ VarCharPtr: testutils.PtrOf("ABBA"),
VarChar: "ABBA",
- CharPtr: testutils.StringPtr("JOHN "),
+ CharPtr: testutils.PtrOf("JOHN "),
Char: "JOHN ",
- TextPtr: testutils.StringPtr("Some text"),
+ TextPtr: testutils.PtrOf("Some text"),
Text: "Some text",
- ByteaPtr: testutils.ByteArrayPtr([]byte("bytea")),
+ ByteaPtr: testutils.PtrOf([]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 +1342,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.StringPtr("3 days 04:05:06"),
+ IntervalPtr: testutils.PtrOf("3 days 04:05:06"),
Interval: "3 days 04:05:06",
- BooleanPtr: testutils.BoolPtr(true),
+ BooleanPtr: testutils.PtrOf(true),
Boolean: false,
- PointPtr: testutils.StringPtr("(2,3)"),
- BitPtr: testutils.StringPtr("101"),
+ PointPtr: testutils.PtrOf("(2,3)"),
+ BitPtr: testutils.PtrOf("101"),
Bit: "101",
- BitVaryingPtr: testutils.StringPtr("101111"),
+ BitVaryingPtr: testutils.PtrOf("101111"),
BitVarying: "101111",
- TsvectorPtr: testutils.StringPtr("'supernova':1"),
+ TsvectorPtr: testutils.PtrOf("'supernova':1"),
Tsvector: "'supernova':1",
UUIDPtr: testutils.UUIDPtr("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
UUID: uuid.MustParse("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"),
- XMLPtr: testutils.StringPtr("abc"),
+ XMLPtr: testutils.PtrOf("abc"),
XML: "abc",
- JSONPtr: testutils.StringPtr(`{"a": 1, "b": 3}`),
+ JSONPtr: testutils.PtrOf(`{"a": 1, "b": 3}`),
JSON: `{"a": 1, "b": 3}`,
- JsonbPtr: testutils.StringPtr(`{"a": 1, "b": 3}`),
+ JsonbPtr: testutils.PtrOf(`{"a": 1, "b": 3}`),
Jsonb: `{"a": 1, "b": 3}`,
- IntegerArrayPtr: testutils.StringPtr("{1,2,3}"),
+ IntegerArrayPtr: testutils.PtrOf("{1,2,3}"),
IntegerArray: "{1,2,3}",
- TextArrayPtr: testutils.StringPtr("{breakfast,consulting}"),
+ TextArrayPtr: testutils.PtrOf("{breakfast,consulting}"),
TextArray: "{breakfast,consulting}",
JsonbArray: `{"{\"a\": 1, \"b\": 2}","{\"a\": 3, \"b\": 4}"}`,
- TextMultiDimArrayPtr: testutils.StringPtr("{{meeting,lunch},{training,presentation}}"),
+ TextMultiDimArrayPtr: testutils.PtrOf("{{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 afc4842..7c7f957 100644
--- a/tests/postgres/chinook_db_test.go
+++ b/tests/postgres/chinook_db_test.go
@@ -455,7 +455,7 @@ FROM (
require.Len(t, dest, 275)
require.Equal(t, dest[0].Artist1.Artist, model.Artist{
ArtistId: 1,
- Name: testutils.StringPtr("AC/DC"),
+ Name: testutils.PtrOf("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 1df72dd..8d12d0c 100644
--- a/tests/postgres/sample_test.go
+++ b/tests/postgres/sample_test.go
@@ -63,15 +63,15 @@ func TestExactDecimals(t *testing.T) {
Floats: model.Floats{
// overwritten by wrapped(floats) scope
Numeric: 0.1,
- NumericPtr: testutils.Float64Ptr(0.1),
+ NumericPtr: testutils.PtrOf(0.1),
Decimal: 0.1,
- DecimalPtr: testutils.Float64Ptr(0.1),
+ DecimalPtr: testutils.PtrOf(0.1),
// not overwritten
Real: 0.4,
- RealPtr: testutils.Float32Ptr(0.44),
+ RealPtr: testutils.PtrOf(float32(0.44)),
Double: 0.3,
- DoublePtr: testutils.Float64Ptr(0.33),
+ DoublePtr: testutils.PtrOf(0.33),
},
Numeric: decimal.RequireFromString("0.1234567890123456789"),
NumericPtr: decimal.RequireFromString("1.1111111111111111111"),
@@ -378,7 +378,7 @@ ORDER BY employee.employee_id;
FirstName: "Salley",
LastName: "Lester",
EmploymentDate: testutils.TimestampWithTimeZone("1999-01-08 04:05:06 +0100 CET", 1),
- ManagerID: testutils.Int32Ptr(3),
+ ManagerID: testutils.PtrOf(int32(3)),
})
}
@@ -420,7 +420,7 @@ FROM test_sample."WEIRD NAMES TABLE";
WeirdColumnName5: "Doe",
WeirdColumnName6: "Doe",
WeirdColumnName7: "Doe",
- Weirdcolumnname8: testutils.StringPtr("Doe"),
+ Weirdcolumnname8: testutils.PtrOf("Doe"),
WeirdColName9: "Doe",
WeirdColuName10: "Doe",
WeirdColuName11: "Doe",
@@ -518,7 +518,7 @@ func TestMutableColumnsExcludeGeneratedColumn(t *testing.T) {
).MODEL(
model.People{
PeopleName: "Dario",
- PeopleHeightCm: testutils.Float64Ptr(120),
+ PeopleHeightCm: testutils.PtrOf(120.0),
},
).RETURNING(
People.MutableColumns,
diff --git a/tests/postgres/scan_test.go b/tests/postgres/scan_test.go
index 24b5949..b71f49a 100644
--- a/tests/postgres/scan_test.go
+++ b/tests/postgres/scan_test.go
@@ -93,7 +93,7 @@ func TestScanToValidDestination(t *testing.T) {
err := oneInventoryQuery.Query(db, &dest)
require.NoError(t, err)
- require.Equal(t, dest[0], testutils.Int32Ptr(1))
+ require.Equal(t, dest[0], testutils.PtrOf(int32(1)))
})
t.Run("NULL to integer", func(t *testing.T) {
@@ -530,10 +530,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.Int32Ptr(1), testutils.Int32Ptr(2), testutils.Int32Ptr(3), testutils.Int32Ptr(4),
- testutils.Int32Ptr(5), testutils.Int32Ptr(6), testutils.Int32Ptr(7), testutils.Int32Ptr(8)})
+ 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[1].Film, film2)
- testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{testutils.Int32Ptr(9), testutils.Int32Ptr(10)})
+ testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{testutils.PtrOf(int32(9)), testutils.PtrOf(int32(10))})
})
t.Run("complex struct 1", func(t *testing.T) {
@@ -1076,10 +1076,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.StringPtr(""),
+ Address2: testutils.PtrOf(""),
District: "England",
CityID: 312,
- PostalCode: testutils.StringPtr("3433"),
+ PostalCode: testutils.PtrOf("3433"),
Phone: "246810237916",
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
}
@@ -1087,10 +1087,10 @@ var address256 = model.Address{
var addres517 = model.Address{
AddressID: 517,
Address: "548 Uruapan Street",
- Address2: testutils.StringPtr(""),
+ Address2: testutils.PtrOf(""),
District: "Ontario",
CityID: 312,
- PostalCode: testutils.StringPtr("35653"),
+ PostalCode: testutils.PtrOf("35653"),
Phone: "879347453467",
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
}
@@ -1100,12 +1100,12 @@ var customer256 = model.Customer{
StoreID: 2,
FirstName: "Mattie",
LastName: "Hoffman",
- Email: testutils.StringPtr("mattie.hoffman@sakilacustomer.org"),
+ Email: testutils.PtrOf("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.Int32Ptr(1),
+ Active: testutils.PtrOf(int32(1)),
}
var customer512 = model.Customer{
@@ -1113,12 +1113,12 @@ var customer512 = model.Customer{
StoreID: 1,
FirstName: "Cecil",
LastName: "Vines",
- Email: testutils.StringPtr("cecil.vines@sakilacustomer.org"),
+ Email: testutils.PtrOf("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.Int32Ptr(1),
+ Active: testutils.PtrOf(int32(1)),
}
var countryUk = model.Country{
@@ -1151,32 +1151,32 @@ var inventory2 = model.Inventory{
var film1 = model.Film{
FilmID: 1,
Title: "Academy Dinosaur",
- Description: testutils.StringPtr("A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies"),
- ReleaseYear: testutils.Int32Ptr(2006),
+ 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)),
LanguageID: 1,
RentalDuration: 6,
RentalRate: 0.99,
- Length: testutils.Int16Ptr(86),
+ Length: testutils.PtrOf(int16(86)),
ReplacementCost: 20.99,
Rating: &pgRating,
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
- SpecialFeatures: testutils.StringPtr("{\"Deleted Scenes\",\"Behind the Scenes\"}"),
+ SpecialFeatures: testutils.PtrOf("{\"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.StringPtr("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
- ReleaseYear: testutils.Int32Ptr(2006),
+ 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)),
LanguageID: 1,
RentalDuration: 3,
RentalRate: 4.99,
- Length: testutils.Int16Ptr(48),
+ Length: testutils.PtrOf(int16(48)),
ReplacementCost: 12.99,
Rating: &gRating,
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
- SpecialFeatures: testutils.StringPtr(`{Trailers,"Deleted Scenes"}`),
+ SpecialFeatures: testutils.PtrOf(`{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 048db14..94bd68d 100644
--- a/tests/postgres/select_test.go
+++ b/tests/postgres/select_test.go
@@ -1828,16 +1828,16 @@ ORDER BY film.film_id ASC;
testutils.AssertDeepEqual(t, maxRentalRateFilms[0], model.Film{
FilmID: 2,
Title: "Ace Goldfinger",
- Description: testutils.StringPtr("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
- ReleaseYear: testutils.Int32Ptr(2006),
+ 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)),
LanguageID: 1,
RentalRate: 4.99,
- Length: testutils.Int16Ptr(48),
+ Length: testutils.PtrOf(int16(48)),
ReplacementCost: 12.99,
Rating: &gRating,
RentalDuration: 3,
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
- SpecialFeatures: testutils.StringPtr("{Trailers,\"Deleted Scenes\"}"),
+ SpecialFeatures: testutils.PtrOf("{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 +2286,11 @@ ORDER BY customer_payment_sum.amount_sum ASC;
FirstName: "Brian",
LastName: "Wyman",
AddressID: 323,
- Email: testutils.StringPtr("brian.wyman@sakilacustomer.org"),
+ Email: testutils.PtrOf("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.Int32Ptr(1),
+ Active: testutils.PtrOf(int32(1)),
})
require.Equal(t, customersWithAmounts[0].AmountSum, 27.93)
@@ -3133,8 +3133,8 @@ func TestDynamicCondition(t *testing.T) {
Active *bool
}
- request.CustomerID = testutils.Int64Ptr(1)
- request.Active = testutils.BoolPtr(true)
+ request.CustomerID = testutils.PtrOf(int64(1))
+ request.Active = testutils.PtrOf(true)
// ...
@@ -3894,12 +3894,12 @@ var customer0 = model.Customer{
StoreID: 1,
FirstName: "Mary",
LastName: "Smith",
- Email: testutils.StringPtr("mary.smith@sakilacustomer.org"),
+ Email: testutils.PtrOf("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.Int32Ptr(1),
+ Active: testutils.PtrOf(int32(1)),
}
var customer1 = model.Customer{
@@ -3907,12 +3907,12 @@ var customer1 = model.Customer{
StoreID: 1,
FirstName: "Patricia",
LastName: "Johnson",
- Email: testutils.StringPtr("patricia.johnson@sakilacustomer.org"),
+ Email: testutils.PtrOf("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.Int32Ptr(1),
+ Active: testutils.PtrOf(int32(1)),
}
var lastCustomer = model.Customer{
@@ -3920,10 +3920,10 @@ var lastCustomer = model.Customer{
StoreID: 2,
FirstName: "Austin",
LastName: "Cintron",
- Email: testutils.StringPtr("austin.cintron@sakilacustomer.org"),
+ Email: testutils.PtrOf("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.Int32Ptr(1),
+ Active: testutils.PtrOf(int32(1)),
}
diff --git a/tests/sqlite/alltypes_test.go b/tests/sqlite/alltypes_test.go
index 58a9da6..63d1835 100644
--- a/tests/sqlite/alltypes_test.go
+++ b/tests/sqlite/alltypes_test.go
@@ -153,43 +153,43 @@ func TestAllTypesInsert(t *testing.T) {
var toInsert = model.AllTypes{
Boolean: false,
- BooleanPtr: testutils.BoolPtr(true),
+ BooleanPtr: testutils.PtrOf(true),
TinyInt: 1,
SmallInt: 3,
MediumInt: 5,
Integer: 7,
BigInt: 9,
- TinyIntPtr: testutils.Int8Ptr(11),
- SmallIntPtr: testutils.Int16Ptr(33),
- MediumIntPtr: testutils.Int32Ptr(55),
- IntegerPtr: testutils.Int32Ptr(77),
- BigIntPtr: testutils.Int64Ptr(99),
+ 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)),
Decimal: 11.22,
- DecimalPtr: testutils.Float64Ptr(33.44),
+ DecimalPtr: testutils.PtrOf(33.44),
Numeric: 55.66,
- NumericPtr: testutils.Float64Ptr(77.88),
+ NumericPtr: testutils.PtrOf(77.88),
Float: 99.00,
- FloatPtr: testutils.Float64Ptr(11.22),
+ FloatPtr: testutils.PtrOf(11.22),
Double: 33.44,
- DoublePtr: testutils.Float64Ptr(55.66),
+ DoublePtr: testutils.PtrOf(55.66),
Real: 77.88,
- RealPtr: testutils.Float32Ptr(99.00),
+ RealPtr: testutils.PtrOf(float32(99.00)),
Time: time.Date(1, 1, 1, 1, 1, 1, 10, time.UTC),
- TimePtr: testutils.TimePtr(time.Date(2, 2, 2, 2, 2, 2, 200, time.UTC)),
+ TimePtr: testutils.PtrOf(time.Date(2, 2, 2, 2, 2, 2, 200, time.UTC)),
Date: time.Now(),
- DatePtr: testutils.TimePtr(time.Now()),
+ DatePtr: testutils.PtrOf(time.Now()),
DateTime: time.Now(),
- DateTimePtr: testutils.TimePtr(time.Now()),
+ DateTimePtr: testutils.PtrOf(time.Now()),
Timestamp: time.Now(),
- TimestampPtr: testutils.TimePtr(time.Now()),
+ TimestampPtr: testutils.PtrOf(time.Now()),
Char: "abcd",
- CharPtr: testutils.StringPtr("absd"),
+ CharPtr: testutils.PtrOf("absd"),
VarChar: "abcd",
- VarCharPtr: testutils.StringPtr("absd"),
+ VarCharPtr: testutils.PtrOf("absd"),
Blob: []byte("large file"),
- BlobPtr: testutils.ByteArrayPtr([]byte("very large file")),
+ BlobPtr: testutils.PtrOf([]byte("very large file")),
Text: "some text",
- TextPtr: testutils.StringPtr("text"),
+ TextPtr: testutils.PtrOf("text"),
}
func TestUUID(t *testing.T) {
@@ -659,7 +659,7 @@ func TestExactDecimals(t *testing.T) {
// not overwritten
Numeric: "6.7",
- NumericPtr: testutils.StringPtr("7.7"),
+ NumericPtr: testutils.PtrOf("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 776d546..5e9c7b2 100644
--- a/tests/sqlite/insert_test.go
+++ b/tests/sqlite/insert_test.go
@@ -49,7 +49,7 @@ VALUES (?, ?, ?, ?),
ID: 101,
URL: "http://www.google.com",
Name: "Google",
- Description: testutils.StringPtr("Search engine"),
+ Description: testutils.PtrOf("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 4775eeb..7349d76 100644
--- a/tests/sqlite/sample_test.go
+++ b/tests/sqlite/sample_test.go
@@ -54,7 +54,7 @@ WHERE people.people_id = ?;
).MODEL(
model.People{
PeopleName: "Dario",
- PeopleHeightCm: testutils.Float64Ptr(190),
+ PeopleHeightCm: testutils.PtrOf(190.0),
},
).RETURNING(
People.AllColumns,
diff --git a/tests/sqlite/select_test.go b/tests/sqlite/select_test.go
index 63d43a9..da4fa71 100644
--- a/tests/sqlite/select_test.go
+++ b/tests/sqlite/select_test.go
@@ -846,15 +846,15 @@ func TestSimpleView(t *testing.T) {
require.Equal(t, len(dest), 10)
require.Equal(t, dest[2], model.CustomerList{
- ID: testutils.Int32Ptr(3),
- Name: testutils.StringPtr("LINDA WILLIAMS"),
- Address: testutils.StringPtr("692 Joliet Street"),
- ZipCode: testutils.StringPtr("83579"),
- Phone: testutils.StringPtr(" "),
- City: testutils.StringPtr("Athenai"),
- Country: testutils.StringPtr("Greece"),
- Notes: testutils.StringPtr("active"),
- Sid: testutils.Int32Ptr(1),
+ 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)),
})
}