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