From 1be3c2cf3bcef54b36a7b1e0484fd1fed54c443d Mon Sep 17 00:00:00 2001 From: myyrakle Date: Wed, 25 Oct 2023 01:58:17 +0900 Subject: [PATCH 1/2] [#17] fix case convert --- src/output/mongery.ts | 17 ++++++++++++----- test/pg/test_for_go2.sql | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 test/pg/test_for_go2.sql diff --git a/src/output/mongery.ts b/src/output/mongery.ts index 28032dc..561ae24 100644 --- a/src/output/mongery.ts +++ b/src/output/mongery.ts @@ -6,6 +6,16 @@ import Table from "../types/table"; import { convertNameCaseByOption } from "../util.ts/name"; import { TAB } from "../util.ts/tab"; +// 첫번째 문자만 대문자로 변경 +function convertToPascal(original: string) { + return original.charAt(0).toUpperCase() + original.slice(1); +} + +// 첫번째 문자만 소문자로 변경 +function convertToCamel(original: string) { + return original.charAt(0).toLowerCase() + original.slice(1); +} + export class MongeryEmitter implements IEmmiter { private option: IOption; @@ -26,17 +36,14 @@ export class MongeryEmitter implements IEmmiter { column.dbType = this.replaceType(column.dbType); - let fieldName = convertNameCaseByOption("PASCAL", column.name); + let fieldName = convertToPascal(column.name); if (column.name === "_id") { fieldName = "ID"; isPrimaryKey = true; } - const bsonName = - column.name == "_id" - ? "_id" - : convertNameCaseByOption("CAMEL", column.name); + const bsonName = convertToCamel(column.name); // PrimaryKey 강제 추가 옵션 if (column.name == this.option.autoAddPrimaryKey) { diff --git a/test/pg/test_for_go2.sql b/test/pg/test_for_go2.sql new file mode 100644 index 0000000..7e3c1a8 --- /dev/null +++ b/test/pg/test_for_go2.sql @@ -0,0 +1,25 @@ +CREATE TABLE "payment_method" ( + "_id" ObjectID NOT NULL, + "shopID" ObjectID NOT NULL, + "cardName" string NULL, + "cardAlias" string NULL, + "isDefault" bool NULL, + "customer_uid" string NULL, + "merchant_uid" string NULL, + "email" string NULL, + "cardNumber" string NULL, + "expirePeriod" string NULL, + "cardCompany" string NULL, + "createDate" Time NULL, + "deleteDate" Time NULL +); + +COMMENT ON COLUMN "payment_method"."cardAlias" IS '결제수단 별명'; + +COMMENT ON COLUMN "payment_method"."cardNumber" IS '마스킹'; + +COMMENT ON COLUMN "payment_method"."expirePeriod" IS '마스킹'; + +ALTER TABLE "payment_method" ADD CONSTRAINT "PK_PAYMENT_METHOD" PRIMARY KEY ( + "_id" +); \ No newline at end of file From 419264fc193d8533399a3add28254e0b068db9bc Mon Sep 17 00:00:00 2001 From: myyrakle Date: Wed, 25 Oct 2023 01:58:45 +0900 Subject: [PATCH 2/2] v0.10.5 --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 946af73..4c23ba2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # eojuk -![](https://img.shields.io/badge/language-Typescript-yellow) ![](https://img.shields.io/badge/version-0.10.4-brightgreen) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)]() +![](https://img.shields.io/badge/language-Typescript-yellow) ![](https://img.shields.io/badge/version-0.10.5-brightgreen) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)]() 어죽은 테이블 작성 쿼리를 ORM 코드들로 변환해주는 유용한 도구입니다. 기존 RAW Query를 마이그레이션하거나 ERD 도구에서 추출해낸 쿼리를 기반으로 엔티티 코드를 작성하기 좋습니다. diff --git a/package.json b/package.json index f66fe48..daba1e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eojuk", - "version": "0.10.4", + "version": "0.10.5", "description": "", "keywords": [ "mysql",