mirror of
				https://github.com/Fabio286/antares.git
				synced 2025-06-05 21:59:22 +02:00 
			
		
		
		
	fix(MySQL): error with ANSI sql_mode
This commit is contained in:
		| @@ -192,14 +192,14 @@ export class MySQLClient extends AntaresCore { | |||||||
|  |  | ||||||
|       // ANSI_QUOTES check |       // ANSI_QUOTES check | ||||||
|       const [response] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\''); |       const [response] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\''); | ||||||
|       const sqlMode = response[0]?.Value?.split(','); |       const sqlMode: string[] = response[0]?.Value?.split(','); | ||||||
|       const hasAnsiQuotes = sqlMode.includes('ANSI_QUOTES'); |       const hasAnsiQuotes = sqlMode.includes('ANSI') || sqlMode.includes('ANSI_QUOTES'); | ||||||
|  |  | ||||||
|       if (this._params.readonly) |       if (this._params.readonly) | ||||||
|          await connection.query('SET SESSION TRANSACTION READ ONLY'); |          await connection.query('SET SESSION TRANSACTION READ ONLY'); | ||||||
|  |  | ||||||
|       if (hasAnsiQuotes) |       if (hasAnsiQuotes) | ||||||
|          await connection.query(`SET SESSION sql_mode = "${sqlMode.filter((m: string) => m !== 'ANSI_QUOTES').join(',')}"`); |          await connection.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`); | ||||||
|  |  | ||||||
|       return connection; |       return connection; | ||||||
|    } |    } | ||||||
| @@ -219,18 +219,18 @@ export class MySQLClient extends AntaresCore { | |||||||
|  |  | ||||||
|       // ANSI_QUOTES check |       // ANSI_QUOTES check | ||||||
|       const [res] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\''); |       const [res] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\''); | ||||||
|       const sqlMode = res[0]?.Value?.split(','); |       const sqlMode: string[] = res[0]?.Value?.split(','); | ||||||
|       const hasAnsiQuotes = sqlMode.includes('ANSI_QUOTES'); |       const hasAnsiQuotes = sqlMode.includes('ANSI') || sqlMode.includes('ANSI_QUOTES'); | ||||||
|  |  | ||||||
|       if (hasAnsiQuotes) |       if (hasAnsiQuotes) | ||||||
|          await connection.query(`SET SESSION sql_mode = "${sqlMode.filter((m: string) => m !== 'ANSI_QUOTES').join(',')}"`); |          await connection.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`); | ||||||
|  |  | ||||||
|       connection.on('connection', conn => { |       connection.on('connection', conn => { | ||||||
|          if (this._params.readonly) |          if (this._params.readonly) | ||||||
|             conn.query('SET SESSION TRANSACTION READ ONLY'); |             conn.query('SET SESSION TRANSACTION READ ONLY'); | ||||||
|  |  | ||||||
|          if (hasAnsiQuotes) |          if (hasAnsiQuotes) | ||||||
|             conn.query(`SET SESSION sql_mode = "${sqlMode.filter((m: string) => m !== 'ANSI_QUOTES').join(',')}"`); |             conn.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`); | ||||||
|       }); |       }); | ||||||
|  |  | ||||||
|       return connection; |       return connection; | ||||||
| @@ -1397,7 +1397,7 @@ export class MySQLClient extends AntaresCore { | |||||||
|    } |    } | ||||||
|  |  | ||||||
|    async getVersion () { |    async getVersion () { | ||||||
|       const sql = 'SHOW VARIABLES LIKE "%vers%"'; |       const sql = 'SHOW VARIABLES LIKE \'%vers%\''; | ||||||
|       const { rows } = await this.raw(sql); |       const { rows } = await this.raw(sql); | ||||||
|  |  | ||||||
|       return rows.reduce((acc, curr) => { |       return rows.reduce((acc, curr) => { | ||||||
|   | |||||||
| @@ -23,12 +23,13 @@ test('main window elements visibility', async () => { | |||||||
|    const visibleSelectors = [ |    const visibleSelectors = [ | ||||||
|       // '#titlebar', |       // '#titlebar', | ||||||
|       '#window-content', |       '#window-content', | ||||||
|       '#settingbar' |       '#settingbar', | ||||||
|       // '#footer' |       '#footer' | ||||||
|    ]; |    ]; | ||||||
|  |    setTimeout(async () => { | ||||||
|    for (const selector of visibleSelectors) |       for (const selector of visibleSelectors) | ||||||
|       expect(await appWindow.isVisible(selector), `expect ${selector} visible`).toBe(true); |          expect(await appWindow.isVisible(selector), `expect ${selector} visible`).toBe(true); | ||||||
|  |    }, 3000); | ||||||
| }); | }); | ||||||
|  |  | ||||||
| // test('SQLite connection', async () => {// FIXME: not working on GitHub Actions | // test('SQLite connection', async () => {// FIXME: not working on GitHub Actions | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user