From b0ea913f4ef903590221dee3699dbd39b6fc9986 Mon Sep 17 00:00:00 2001 From: John Chan Date: Wed, 19 Mar 2025 19:13:12 +0800 Subject: [PATCH] feat(postgres): support macaddr8 column type Signed-off-by: John Chan --- docs/entities.md | 2 +- docs/zh_CN/entities.md | 2 +- src/driver/postgres/PostgresDriver.ts | 1 + src/driver/types/ColumnTypes.ts | 1 + .../column-types/postgres/column-types-postgres.ts | 5 +++++ .../database-schema/column-types/postgres/entity/Post.ts | 3 +++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/entities.md b/docs/entities.md index 81d802508..3147fce54 100644 --- a/docs/entities.md +++ b/docs/entities.md @@ -388,7 +388,7 @@ or `character`, `char`, `text`, `citext`, `hstore`, `bytea`, `bit`, `varbit`, `bit varying`, `timetz`, `timestamptz`, `timestamp`, `timestamp without time zone`, `timestamp with time zone`, `date`, `time`, `time without time zone`, `time with time zone`, `interval`, `bool`, `boolean`, -`enum`, `point`, `line`, `lseg`, `box`, `path`, `polygon`, `circle`, `cidr`, `inet`, `macaddr`, +`enum`, `point`, `line`, `lseg`, `box`, `path`, `polygon`, `circle`, `cidr`, `inet`, `macaddr`, `macaddr8`, `tsvector`, `tsquery`, `uuid`, `xml`, `json`, `jsonb`, `int4range`, `int8range`, `numrange`, `tsrange`, `tstzrange`, `daterange`, `int4multirange`, `int8multirange`, `nummultirange`, `tsmultirange`, `tstzmultirange`, `multidaterange`, `geometry`, `geography`, `cube`, `ltree` diff --git a/docs/zh_CN/entities.md b/docs/zh_CN/entities.md index 138ad8be4..51e70be93 100644 --- a/docs/zh_CN/entities.md +++ b/docs/zh_CN/entities.md @@ -274,7 +274,7 @@ TypeORM 支持所有最常用的数据库支持的列类型。 `character`, `char`, `text`, `citext`, `hstore`, `bytea`, `bit`, `varbit`, `bit varying`, `timetz`, `timestamptz`, `timestamp`, `timestamp without time zone`, `timestamp with time zone`, `date`, `time`, `time without time zone`, `time with time zone`, `interval`, `bool`, `boolean`, -`enum`, `point`, `line`, `lseg`, `box`, `path`, `polygon`, `circle`, `cidr`, `inet`, `macaddr`, +`enum`, `point`, `line`, `lseg`, `box`, `path`, `polygon`, `circle`, `cidr`, `inet`, `macaddr`, `macaddr8`, `tsvector`, `tsquery`, `uuid`, `xml`, `json`, `jsonb`, `int4range`, `int8range`, `numrange`, `tsrange`, `tstzrange`, `daterange`, `int4multirange`, `int8multirange`, `nummultirange`, `tsmultirange`, `tstzmultirange`, `multidaterange`, `geometry`, `geography` diff --git a/src/driver/postgres/PostgresDriver.ts b/src/driver/postgres/PostgresDriver.ts index 837618f94..fe79dc627 100644 --- a/src/driver/postgres/PostgresDriver.ts +++ b/src/driver/postgres/PostgresDriver.ts @@ -168,6 +168,7 @@ export class PostgresDriver implements Driver { "cidr", "inet", "macaddr", + "macaddr8", "tsvector", "tsquery", "uuid", diff --git a/src/driver/types/ColumnTypes.ts b/src/driver/types/ColumnTypes.ts index 3954766d9..f9771c601 100644 --- a/src/driver/types/ColumnTypes.ts +++ b/src/driver/types/ColumnTypes.ts @@ -188,6 +188,7 @@ export type SimpleColumnType = | "inet4" // mariadb | "inet6" // mariadb | "macaddr" // postgres + | "macaddr8" // postgres | "bit" // postgres, mssql | "bit varying" // postgres | "varbit" // postgres diff --git a/test/functional/database-schema/column-types/postgres/column-types-postgres.ts b/test/functional/database-schema/column-types/postgres/column-types-postgres.ts index 36d859a9f..4250af418 100644 --- a/test/functional/database-schema/column-types/postgres/column-types-postgres.ts +++ b/test/functional/database-schema/column-types/postgres/column-types-postgres.ts @@ -85,6 +85,7 @@ describe("database schema > column types > postgres", () => { post.cidr = "192.168.100.128/25" post.inet = "192.168.100.128" post.macaddr = "08:00:2b:01:02:03" + post.macaddr8 = "08:00:2b:01:02:03:04:05" post.bit = "1" post.varbit = "100" post.bitVarying = "00" @@ -178,6 +179,7 @@ describe("database schema > column types > postgres", () => { loadedPost.cidr.should.be.equal(post.cidr) loadedPost.inet.should.be.equal(post.inet) loadedPost.macaddr.should.be.equal(post.macaddr) + loadedPost.macaddr8.should.be.equal(post.macaddr8) loadedPost.bit.should.be.equal(post.bit) loadedPost.varbit.should.be.equal(post.varbit) loadedPost.bitVarying.should.be.equal(post.bitVarying) @@ -308,6 +310,9 @@ describe("database schema > column types > postgres", () => { table! .findColumnByName("macaddr")! .type.should.be.equal("macaddr") + table! + .findColumnByName("macaddr8")! + .type.should.be.equal("macaddr8") table!.findColumnByName("bit")!.type.should.be.equal("bit") table! .findColumnByName("varbit")! diff --git a/test/functional/database-schema/column-types/postgres/entity/Post.ts b/test/functional/database-schema/column-types/postgres/entity/Post.ts index 333e19f0e..cf051d4fd 100644 --- a/test/functional/database-schema/column-types/postgres/entity/Post.ts +++ b/test/functional/database-schema/column-types/postgres/entity/Post.ts @@ -175,6 +175,9 @@ export class Post { @Column("macaddr") macaddr: string + @Column("macaddr8") + macaddr8: string + // ------------------------------------------------------------------------- // Bit String Type // -------------------------------------------------------------------------