Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tests/ActiveQueryFindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,31 +652,30 @@ public function testFindCompositeRelationAsArray(): void
->asArray()
->all();

$isOracle = self::db()->getDriverName() === 'oci';
$this->assertSame(
[
[
'order_id' => 1,
'item_id' => 1,
'quantity' => 1,
'subtotal' => $isOracle ? 30 : 30.0,
'subtotal' => 30.0,
'orderItemCompositeNoJoin' => [
'order_id' => 1,
'item_id' => 1,
'quantity' => 1,
'subtotal' => $isOracle ? 30 : 30.0,
'subtotal' => 30.0,
],
],
[
'order_id' => 1,
'item_id' => 2,
'quantity' => 2,
'subtotal' => $isOracle ? 40 : 40.0,
'subtotal' => 40.0,
'orderItemCompositeNoJoin' => [
'order_id' => 1,
'item_id' => 2,
'quantity' => 2,
'subtotal' => $isOracle ? 40 : 40.0,
'subtotal' => 40.0,
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion tests/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function testDefaultValues(): void
$this->assertSame(1, $arClass->int_col2);
$this->assertSame('something', $arClass->char_col2);
$this->assertSame(1.23, $arClass->float_col2);
$this->assertSame(33.22, $arClass->numeric_col);
$this->assertSame('33.22', $arClass->numeric_col);
$this->assertTrue($arClass->bool_col2);
$this->assertSame('2002-01-01 00:00:00', $arClass->time);

Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Oracle/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testDefaultValues(): void
$this->assertSame(1, $arClass->int_col2);
$this->assertSame('something', $arClass->char_col2);
$this->assertSame(1.23, $arClass->float_col2);
$this->assertSame(33.22, $arClass->numeric_col);
$this->assertSame('33.22', $arClass->numeric_col);
$this->assertTrue($arClass->bool_col2);

// not testing $arClass->time, because oci\Schema can't read default value
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Oracle/MagicActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testDefaultValues(): void
$this->assertSame(1, $arClass->int_col2);
$this->assertSame('something', $arClass->char_col2);
$this->assertSame(1.23, $arClass->float_col2);
$this->assertSame(33.22, $arClass->numeric_col);
$this->assertSame('33.22', $arClass->numeric_col);
$this->assertSame(true, $arClass->bool_col2);

// not testing $arClass->time, because oci\Schema can't read default value
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/Pgsql/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testDefaultValues(): void
$this->assertSame(1, $arClass->int_col2);
$this->assertSame('something', $arClass->char_col2);
$this->assertSame(1.23, $arClass->float_col2);
$this->assertSame(33.22, $arClass->numeric_col);
$this->assertSame('33.22', $arClass->numeric_col);
$this->assertTrue($arClass->bool_col2);
$this->assertSame('2002-01-01 00:00:00', $arClass->time);
$this->assertSame(['a' => 1], $arClass->json_col);
Expand Down
2 changes: 1 addition & 1 deletion tests/MagicActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function testDefaultValues(): void
$this->assertEquals(1, $arClass->int_col2);
$this->assertEquals('something', $arClass->char_col2);
$this->assertEquals(1.23, $arClass->float_col2);
$this->assertEquals(33.22, $arClass->numeric_col);
$this->assertEquals('33.22', $arClass->numeric_col);
$this->assertTrue($arClass->bool_col2);

if ($this->db()->getDriverName() === 'mysql') {
Expand Down
2 changes: 1 addition & 1 deletion tests/Stubs/ActiveRecord/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Customer extends ArrayableActiveRecord
public const STATUS_INACTIVE = 2;

public int|string $status2;
public int|string|null $sumTotal;
public float|string|null $sumTotal;

protected int $id;
protected string $email;
Expand Down
2 changes: 1 addition & 1 deletion tests/Stubs/ActiveRecord/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Type extends ActiveRecord
public float $float_col;
public ?float $float_col2 = 1.23;
public mixed $blob_col;
public ?float $numeric_col = 33.22;
public ?string $numeric_col = '33.22';
public string|DateTimeInterface|Expression $time = '2002-01-01 00:00:00';
public bool|int|string $bool_col;
public bool|int|string|null $bool_col2 = true;
Expand Down
12 changes: 6 additions & 6 deletions tests/data/mssql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ CREATE TABLE [dbo].[order] (
[created_at] [int] NOT NULL,
[updated_at] [int] NOT NULL,
[deleted_at] [int],
[total] [decimal](10,0) NOT NULL,
[total] [float] NOT NULL,
CONSTRAINT [PK_order] PRIMARY KEY CLUSTERED (
[id] ASC
) ON [PRIMARY]
Expand All @@ -100,7 +100,7 @@ CREATE TABLE [dbo].[order_with_null_fk] (
[id] [int] IDENTITY NOT NULL,
[customer_id] [int] ,
[created_at] [int] NOT NULL,
[total] [decimal](10,0) NOT NULL,
[total] [float] NOT NULL,
CONSTRAINT [PK_order_with_null_fk] PRIMARY KEY CLUSTERED (
[id] ASC
) ON [PRIMARY]
Expand All @@ -110,7 +110,7 @@ CREATE TABLE [dbo].[order_item] (
[order_id] [int] NOT NULL,
[item_id] [int] NOT NULL,
[quantity] [int] NOT NULL,
[subtotal] [decimal](10,0) NOT NULL,
[subtotal] [float] NOT NULL,
CONSTRAINT [PK_order_item] PRIMARY KEY CLUSTERED (
[order_id] ASC,
[item_id] ASC
Expand All @@ -121,7 +121,7 @@ CREATE TABLE "order_item_name" (
[order_id] [int] NOT NULL,
[item_name] [varchar](128) NOT NULL,
[quantity] [int] NOT NULL,
[subtotal] [decimal](10,0) NOT NULL,
[subtotal] [float] NOT NULL,
PRIMARY KEY ([order_id], [item_name])
);

Expand All @@ -141,7 +141,7 @@ CREATE TABLE [dbo].[order_item_with_null_fk] (
[order_id] [int],
[item_id] [int],
[quantity] [int] NOT NULL,
[subtotal] [decimal](10,0) NOT NULL
[subtotal] [float] NOT NULL
);

CREATE TABLE [dbo].[null_values] (
Expand Down Expand Up @@ -170,7 +170,7 @@ CREATE TABLE [dbo].[type] (
[char_col] [char](100) NOT NULL,
[char_col2] [varchar](100) DEFAULT 'something',
[char_col3] [text],
[float_col] [decimal](4,3) NOT NULL,
[float_col] [float] NOT NULL,
[float_col2] [float] DEFAULT '1.23',
[blob_col] [varbinary](MAX),
[numeric_col] [decimal](5,2) DEFAULT '33.22',
Expand Down
10 changes: 5 additions & 5 deletions tests/data/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ CREATE TABLE `order` (
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`deleted_at` int(11),
`total` decimal(10,0) NOT NULL,
`total` float NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `FK_order_customer_id` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Expand All @@ -116,15 +116,15 @@ CREATE TABLE `order_with_null_fk` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11),
`created_at` int(11) NOT NULL,
`total` decimal(10,0) NOT NULL,
`total` float NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `order_item` (
`order_id` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`quantity` int(11) NOT NULL,
`subtotal` decimal(10,0) NOT NULL,
`subtotal` float NOT NULL,
PRIMARY KEY (`order_id`,`item_id`),
KEY `FK_order_item_item_id` (`item_id`),
CONSTRAINT `FK_order_item_order_id` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON DELETE CASCADE,
Expand All @@ -135,15 +135,15 @@ CREATE TABLE `order_item_name` (
`order_id` int(11) NOT NULL,
`item_name` varchar(128) NOT NULL,
`quantity` int(11) NOT NULL,
`subtotal` decimal(10,0) NOT NULL,
`subtotal` float NOT NULL,
PRIMARY KEY (`order_id`, `item_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `order_item_with_null_fk` (
`order_id` int(11),
`item_id` int(11),
`quantity` int(11) NOT NULL,
`subtotal` decimal(10,0) NOT NULL
`subtotal` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `composite_fk` (
Expand Down
10 changes: 5 additions & 5 deletions tests/data/oci.sql
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ CREATE TABLE "order" (
"created_at" integer NOT NULL,
"updated_at" integer NOT NULL,
"deleted_at" integer,
"total" decimal(10,0) NOT NULL,
"total" float NOT NULL,
CONSTRAINT "order_PK" PRIMARY KEY ("id") ENABLE
);
CREATE SEQUENCE "order_SEQ";
Expand All @@ -129,7 +129,7 @@ CREATE TABLE "order_with_null_fk" (
"id" integer not null,
"customer_id" integer,
"created_at" integer NOT NULL,
"total" decimal(10,0) NOT NULL,
"total" float NOT NULL,
CONSTRAINT "order_with_null_fk_PK" PRIMARY KEY ("id") ENABLE
);
CREATE SEQUENCE "order_with_null_fk_SEQ";
Expand All @@ -138,23 +138,23 @@ CREATE TABLE "order_item" (
"order_id" integer NOT NULL references "order"("id") on DELETE CASCADE,
"item_id" integer NOT NULL references "item"("id") on DELETE CASCADE,
"quantity" integer NOT NULL,
"subtotal" decimal(10,0) NOT NULL,
"subtotal" float NOT NULL,
CONSTRAINT "order_item_PK" PRIMARY KEY ("order_id", "item_id") ENABLE
);

CREATE TABLE "order_item_name" (
"order_id" integer NOT NULL,
"item_name" varchar2(128) NOT NULL,
"quantity" integer NOT NULL,
"subtotal" decimal(10,0) NOT NULL,
"subtotal" float NOT NULL,
CONSTRAINT "order_item_name_PK" PRIMARY KEY ("order_id", "item_name") ENABLE
);

CREATE TABLE "order_item_with_null_fk" (
"order_id" integer,
"item_id" integer,
"quantity" integer NOT NULL,
"subtotal" decimal(10,0) NOT NULL
"subtotal" float NOT NULL
);

CREATE TABLE "composite_fk" (
Expand Down
10 changes: 5 additions & 5 deletions tests/data/pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -123,37 +123,37 @@ CREATE TABLE "order" (
created_at integer NOT NULL,
updated_at integer NOT NULL,
deleted_at integer,
total decimal(10,0) NOT NULL
total float NOT NULL
);

CREATE TABLE "order_with_null_fk" (
id serial not null primary key,
customer_id integer,
created_at integer NOT NULL,
total decimal(10,0) NOT NULL
total float NOT NULL
);

CREATE TABLE "order_item" (
order_id integer NOT NULL references "order"(id) on UPDATE CASCADE on DELETE CASCADE,
item_id integer NOT NULL references "item"(id) on UPDATE CASCADE on DELETE CASCADE,
quantity integer NOT NULL,
subtotal decimal(10,0) NOT NULL,
subtotal float NOT NULL,
PRIMARY KEY (order_id, item_id)
);

CREATE TABLE "order_item_name" (
order_id integer NOT NULL,
item_name varchar(128) NOT NULL,
quantity integer NOT NULL,
subtotal decimal(10,0) NOT NULL,
subtotal float NOT NULL,
PRIMARY KEY (order_id, item_name)
);

CREATE TABLE "order_item_with_null_fk" (
order_id integer,
item_id integer,
quantity integer NOT NULL,
subtotal decimal(10,0) NOT NULL
subtotal float NOT NULL
);

CREATE TABLE "composite_fk" (
Expand Down
10 changes: 5 additions & 5 deletions tests/data/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,39 @@ CREATE TABLE "order" (
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
deleted_at INTEGER,
total decimal(10,0) NOT NULL,
total float NOT NULL,
PRIMARY KEY (id)
);

CREATE TABLE "order_with_null_fk" (
id INTEGER NOT NULL,
customer_id INTEGER,
created_at INTEGER NOT NULL,
total decimal(10,0) NOT NULL,
total float NOT NULL,
PRIMARY KEY (id)
);

CREATE TABLE "order_item" (
order_id INTEGER NOT NULL,
item_id INTEGER NOT NULL,
quantity INTEGER NOT NULL,
subtotal decimal(10,0) NOT NULL,
subtotal float NOT NULL,
PRIMARY KEY (order_id, item_id)
);

CREATE TABLE "order_item_name" (
order_id INTEGER NOT NULL,
item_name VARCHAR(128) NOT NULL,
quantity INTEGER NOT NULL,
subtotal decimal(10,0) NOT NULL,
subtotal float NOT NULL,
PRIMARY KEY (order_id, item_name)
);

CREATE TABLE "order_item_with_null_fk" (
order_id INTEGER,
item_id INTEGER,
quantity INTEGER NOT NULL,
subtotal decimal(10,0) NOT NULL
subtotal float NOT NULL
);

CREATE TABLE "composite_fk" (
Expand Down
Loading