question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@CreateDateColumn @UpdateDateColumn in MariaDb throwing ER_PARSE_ERROR for date values

See original GitHub issue

Issue type:

[x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [x] mysql / mariadb [ ] oracle [ ] postgres [ ] cockroachdb [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[x] latest [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

following a tuturial, but using mariadb 10.4.11 instead of postgres.

const conn = await createConnection({
		type: "mariadb",
		database: "test",
		username: "test",
		password: "test",
		logging: true,
		synchronize: true,
		entities: [User],
	});

Entity:

import { ObjectType, Field, Int } from "type-graphql";
import {
	BaseEntity,
	Column,
	CreateDateColumn,
	Entity,
	PrimaryGeneratedColumn,
	UpdateDateColumn,
} from "typeorm";

@ObjectType()
@Entity()
export class User extends BaseEntity {
	@Field(() => Int)
	@PrimaryGeneratedColumn()
	id!: number;

	@Field(() => String)
	@CreateDateColumn()
	createdAt = Date;

	@Field(() => String)
	@UpdateDateColumn()
	updatedAt = Date;

	@Field()
	@Column({ unique: true })
	username!: string;

	@Field()
	@Column({ unique: true })
	email!: string;

	@Column()
	password!: string;
}

Try to save a new user:

	const user = new User();
	user.username = options.username;
	user.password = hashedPassword;
	user.email = options.email;
	await user.save();

and am getting this in the logs:

START TRANSACTION
query: INSERT INTO `user`(`id`, `createdAt`, `updatedAt`, `username`, `email`, `password`) VALUES (DEFAULT, Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), ?, ?, ?) -- PARAMETERS: ["kelly2","kelly.milligan2@gmail.com","$argon2i$v=19$m=4096,t=3,p=1$g6yuIcL+0Nqi2vOoYIbvvA$0wMZrSJvekmJ4WuMzkE59fOAxz9kC1PmVzGlj4Hjd8Y"]
query failed: INSERT INTO `user`(`id`, `createdAt`, `updatedAt`, `username`, `email`, `password`) VALUES (DEFAULT, Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), ?, ?, ?) -- PARAMETERS: ["kelly2","kelly.milligan2@gmail.com","$argon2i$v=19$m=4096,t=3,p=1$g6yuIcL+0Nqi2vOoYIbvvA$0wMZrSJvekmJ4WuMzkE59fOAxz9kC1PmVzGlj4Hjd8Y"]
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 'Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 ' at line 1
    at Query.Sequence._packetToError (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:307:12)
    --------------------
    at Protocol._enqueue (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at PoolConnection.query (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/Connection.js:198:25)
    at MysqlQueryRunner.<anonymous> (/Users/kelly/lireddit/liredditserver/node_modules/typeorm/driver/mysql/MysqlQueryRunner.js:159:44)
    at step (/Users/kelly/lireddit/liredditserver/node_modules/tslib/tslib.js:141:27)
    at Object.next (/Users/kelly/lireddit/liredditserver/node_modules/tslib/tslib.js:122:57)
    at fulfilled (/Users/kelly/lireddit/liredditserver/node_modules/tslib/tslib.js:112:62)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: 'ER_PARSE_ERROR',
  errno: 1064,
  sqlMessage: "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 'Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 ' at line 1",
  sqlState: '42000',
  index: 0,
  sql: "INSERT INTO `user`(`id`, `createdAt`, `updatedAt`, `username`, `email`, `password`) VALUES (DEFAULT, Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), 'kelly2', 'kelly.milligan2@gmail.com', '$argon2i$v=19$m=4096,t=3,p=1$g6yuIcL+0Nqi2vOoYIbvvA$0wMZrSJvekmJ4WuMzkE59fOAxz9kC1PmVzGlj4Hjd8Y')"
}
query: ROLLBACK
err:  QueryFailedError: 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 'Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 ' at line 1
    at new QueryFailedError (/Users/kelly/lireddit/liredditserver/node_modules/typeorm/error/QueryFailedError.js:11:28)
    at Query.<anonymous> (/Users/kelly/lireddit/liredditserver/node_modules/typeorm/driver/mysql/MysqlQueryRunner.js:168:45)
    at Query.<anonymous> (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/Connection.js:526:10)
    at Query._callback (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/Connection.js:488:16)
    at Query.Sequence.end (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
    at Query.ErrorPacket (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/sequences/Query.js:92:8)
    at Protocol._parsePacket (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/Users/kelly/lireddit/liredditserver/node_modules/mysql/lib/protocol/Protocol.js:38:16) {
  code: 'ER_PARSE_ERROR',
  errno: 1064,
  sqlMessage: "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 'Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 ' at line 1",
  sqlState: '42000',
  index: 0,
  sql: "INSERT INTO `user`(`id`, `createdAt`, `updatedAt`, `username`, `email`, `password`) VALUES (DEFAULT, Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), 'kelly2', 'kelly.milligan2@gmail.com', '$argon2i$v=19$m=4096,t=3,p=1$g6yuIcL+0Nqi2vOoYIbvvA$0wMZrSJvekmJ4WuMzkE59fOAxz9kC1PmVzGlj4Hjd8Y')",
  query: 'INSERT INTO `user`(`id`, `createdAt`, `updatedAt`, `username`, `email`, `password`) VALUES (DEFAULT, Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), Wed Oct 07 2020 08:51:12 GMT-0500 (Central Daylight Time), ?, ?, ?)',
  parameters: [
    'kelly2',
    'kelly.milligan2@gmail.com',
    '$argon2i$v=19$m=4096,t=3,p=1$g6yuIcL+0Nqi2vOoYIbvvA$0wMZrSJvekmJ4WuMzkE59fOAxz9kC1PmVzGlj4Hjd8Y'
  ]
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kelly-tockcommented, Oct 9, 2020

Ok wow I’m blind 😃 apologies will try that then close.

0reactions
imnotjamescommented, Oct 10, 2020

Closing for now. If it’s still an issue please reopen or open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found