Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MariaDB STORED columns don't accept [NULL | NOT NULL] #7698

Closed
2 of 22 tasks
RyuDoizaki opened this issue May 31, 2021 · 0 comments · Fixed by #7708
Closed
2 of 22 tasks

MariaDB STORED columns don't accept [NULL | NOT NULL] #7698

RyuDoizaki opened this issue May 31, 2021 · 0 comments · Fixed by #7708

Comments

@RyuDoizaki
Copy link

RyuDoizaki commented May 31, 2021

Issue Description

When using MariaDB and creating a STORED column, the correct SQL is not generate.
MariaDB STORED columns don't accept [NULL | NOT NULL].
https://mariadb.com/kb/en/generated-columns/

Expected Behavior

I hope it will generate the correct SQL.

Actual Behavior, Steps to Reproduce

Entity

@Entity('test')
export class TestEntity {

  @PrimaryGeneratedColumn({ type: 'int' })
  readonly id!: number;

  @Column({
    type: 'varchar',
    generatedType: 'STORED',
    asExpression: 'CONCAT(id, "-stored")',
  })
  stored = '';
}

Generated SQL

CREATE TABLE `test` (`id` int NOT NULL AUTO_INCREMENT, `stored` varchar(255) AS (CONCAT(id, "-stored")) STORED NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB

Error Message

error: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB' at line 1

My Environment

Dependency Version
Operating System macOS Catalina 10.15.7
Node.js version v14.16.0
Typescript version v4.2.4
TypeORM version v0.2.32

Additional Context

Relevant Database Driver(s)

  • aurora-data-api
  • aurora-data-api-pg
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • mariadb
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time, and I know how to start.
  • Yes, I have the time, but I don't know how to start. I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants