Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## 1.0.1 under development

- no changes in this release.
- Enh #226: Add support for auto increment in primary key column. (@terabytesoftw)

## 1.0.0 April 12, 2023

- Initial release.
- Initial release.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ your Oracle database and perform various database operations as needed.

| PHP | Oracle Version | CI-Actions
|:----:|:------------------------:|:---:|
|**8.0 - 8.2**| **11 - 21**|[![build](https://github.com/yiisoft/db-oracle/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/actions/workflows/build.yml) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fdb-oracle%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-oracle/master) [![static analysis](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-oracle/coverage.svg)](https://shepherd.dev/github/yiisoft/db-oracle)
|**8.0 - 8.2**| **18 - 21**|[![build](https://github.com/yiisoft/db-oracle/actions/workflows/build.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/actions/workflows/build.yml) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fdb-oracle%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/db-oracle/master) [![static analysis](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml/badge.svg?branch=dev)](https://github.com/yiisoft/db-oracle/actions/workflows/static.yml) [![type-coverage](https://shepherd.dev/github/yiisoft/db-oracle/coverage.svg)](https://shepherd.dev/github/yiisoft/db-oracle)

## Installation

Expand Down
8 changes: 4 additions & 4 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ final class QueryBuilder extends AbstractQueryBuilder
* @psalm-var string[] $typeMap Mapping from abstract column types (keys) to physical column types (values).
*/
protected array $typeMap = [
SchemaInterface::TYPE_PK => 'NUMBER(10) NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_UPK => 'NUMBER(10) UNSIGNED NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_BIGPK => 'NUMBER(20) NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_UBIGPK => 'NUMBER(20) UNSIGNED NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_PK => 'NUMBER(10) GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_UPK => 'NUMBER(10) GENERATED BY DEFAULT AS IDENTITY UNSIGNED NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_BIGPK => 'NUMBER(20) GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_UBIGPK => 'NUMBER(20) GENERATED BY DEFAULT AS IDENTITY UNSIGNED NOT NULL PRIMARY KEY',
SchemaInterface::TYPE_CHAR => 'CHAR(1)',
SchemaInterface::TYPE_STRING => 'VARCHAR2(255)',
SchemaInterface::TYPE_TEXT => 'CLOB',
Expand Down
4 changes: 4 additions & 0 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ protected function findColumns(TableSchemaInterface $table): bool
A.DATA_TYPE,
A.DATA_PRECISION,
A.DATA_SCALE,
A.IDENTITY_COLUMN,
(
CASE A.CHAR_USED WHEN 'C' THEN A.CHAR_LENGTH
ELSE A.DATA_LENGTH
Expand Down Expand Up @@ -366,6 +367,7 @@ protected function findColumns(TableSchemaInterface $table): bool
* data_type: string,
* data_precision: string,
* data_scale: string,
* identity_column: string,
* data_length: string,
* nullable: string,
* data_default: string|null,
Expand Down Expand Up @@ -417,6 +419,7 @@ protected function getTableSequenceName(string $tableName): bool|float|int|strin
* data_type: string,
* data_precision: string,
* data_scale: string,
* identity_column: string,
* data_length: string,
* nullable: string,
* data_default: string|null,
Expand All @@ -430,6 +433,7 @@ protected function createColumnSchema(array $column): ColumnSchemaInterface
$c->allowNull($column['nullable'] === 'Y');
$c->comment($column['column_comment'] ?? '');
$c->primaryKey((int) ($column['is_pk'] ?? 0) > 0);
$c->autoIncrement($column['identity_column'] === 'YES');

$this->extractColumnType(
$c,
Expand Down
2 changes: 1 addition & 1 deletion tests/Provider/SchemaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public static function columns(): array
'phpType' => 'integer',
'primaryKey' => true,
'allowNull' => false,
'autoIncrement' => false,
'autoIncrement' => true,
'enumValues' => null,
'size' => 22,
'precision' => null,
Expand Down
2 changes: 1 addition & 1 deletion tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function testCreateTable(): void
$this->assertSame(
<<<SQL
CREATE TABLE "test" (
\t"id" NUMBER(10) NOT NULL PRIMARY KEY,
\t"id" NUMBER(10) GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY,
\t"name" VARCHAR2(255) NOT NULL,
\t"email" VARCHAR2(255) NOT NULL,
\t"status" NUMBER(10) NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/Fixture/oci.sql
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ CREATE SEQUENCE "bool_values_SEQ";


CREATE TABLE "animal" (
"id" integer,
"id" integer generated by default as identity,
"type" varchar2(255) not null,
CONSTRAINT "animal_PK" PRIMARY KEY ("id") ENABLE
);
Expand Down