RepoDB icon indicating copy to clipboard operation
RepoDB copied to clipboard

Bug: InsertAll<>() fails differently now

Open fake-fur opened this issue 4 years ago • 8 comments

Bug Description

The previous InsertAll<> is now fixed with 1.12.8-b1 but a different InsertAll<> error is now being thrown on a similar simple insert

Exception Message:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT LAST_INSERT_ID() AS `Id`, ? AS `OrderColumn` ; INSERT INTO `syncchecksums' at line 1"}	MySql.Data.MySqlClient.MySqlException

Schema and Model:

Model:

using RepoDb.Attributes;
namespace dsync.Models
{
	[Map("syncchecksums")]
	class HashResult
	{
		[Primary]
		public int recordno { get; set; }
		public string name { get; set; }
		public int date { get; set; }
		public string hash { get; set; }
		public int espsitecode { get; set; }
		public int count { get; set; }
		public string ids { get; set; }
	}
}
CREATE TABLE `syncchecksums` (
	`recordno` INT(11) NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`date` INT(11) NULL DEFAULT NULL,
	`hash` VARCHAR(10000) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	`espsitecode` INT(11) NULL DEFAULT NULL,
	`count` INT(11) NULL DEFAULT NULL,
	`ids` VARCHAR(10000) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
	PRIMARY KEY (`recordno`) USING BTREE,
	UNIQUE INDEX `key_record_no` (`recordno`) USING BTREE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB

RepoDb 1.12.8-beta1 RepoDb.MySql 1.1.4

thanks and sorry for another problem :/

fake-fur avatar Feb 14 '21 13:02 fake-fur

Yeah, it seems related to the issue on the latest release of MySQL.Data. Can you share me the version of MySql.Data library are you using?

and, can you try to set the ignore prepare attribute to true in the connection string?

mikependon avatar Feb 14 '21 14:02 mikependon

mysqlData 8.0.23

ignore prepare set to true stops the crash - is that a setting i can run with in production? or is this a diagnostic test for your debug thinking?

thanks btw

fake-fur avatar Feb 14 '21 14:02 fake-fur

From 8.0.22 to 8.0.23, Oracle changed the default value of this attribute. Prepare is a no_op in MySQL. You can use this in Prod, there are no effects as the previous version is true by default. This is a recommendation from Bradley Graigner directly to me (see my latest Tweet), the creator of MySqlConnector.

mikependon avatar Feb 14 '21 15:02 mikependon

amazing! thanks so much for your time and help :)

fake-fur avatar Feb 15 '21 07:02 fake-fur

hi again - sorry to bother - i have a couple of questions:

  1. i get warnings that ignorePrepare is deprecated - will this cause problems going forward?
  2. how could i set the commandtimeout value for a conn.ExecuteNonQuery() call? been looking through the docs but cannot find anything obvious

otherwise all is working great so thanks again :)

fake-fur avatar Feb 18 '21 13:02 fake-fur

  1. Not on the current version you are using it, but maybe in the future version. But, I would assume that Oracle would fix the no_ops on the Prepare() method.
  2. Simply pass the value to the commandTimeout argument.

mikependon avatar Feb 18 '21 14:02 mikependon

See here.

mikependon avatar Feb 18 '21 14:02 mikependon

thank you again

you can close this issue if you want to :)

fake-fur avatar Feb 18 '21 15:02 fake-fur