Incorrect value when reading from MySQL database
Summary
Text field is not correctly read from MySQL 8.0 service tables
System Information
- Operating system: Linux
- Processor architecture: x86-64
- Compiler version: trunk
- Device: Computer
Steps to reproduce
- Create a database containing foreign keys
CREATE TABLE Customers
(
Id INT PRIMARY KEY AUTO_INCREMENT,
Age INT,
FirstName VARCHAR(20) NOT NULL,
LastName VARCHAR(20) NOT NULL,
Phone VARCHAR(20) NOT NULL UNIQUE
);
CREATE TABLE Orders
(
Id INT PRIMARY KEY AUTO_INCREMENT,
CustomerId INT,
CreatedAt Date,
FOREIGN KEY (CustomerId) REFERENCES Customers (Id)
);
- Connect to the database and run the query
program error_field_value;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
Classes,
SQLDB,
mysql80conn;
var
VConnection: TMySQL80Connection;
VTransaction: TSQLTransaction;
VQuery: TSQLQuery;
begin
VConnection := TMySQL80Connection.Create(nil);
VConnection.HostName := 'localhost';
VConnection.UserName := 'root';
VConnection.Password := '';
VConnection.DatabaseName := 'information_schema';
VTransaction := TSQLTransaction.Create(nil);
VTransaction.SQLConnection := VConnection;
VQuery := TSQLQuery.Create(nil);
VQuery.SQLConnection := VConnection;
VQuery.SQL.Add('SELECT UPDATE_RULE FROM information_schema.REFERENTIAL_CONSTRAINTS;');
VQuery.Open;
while not VQuery.EOF do
begin
if VQuery.FieldByName('UPDATE_RULE').AsString = 'NO ACTIO' then
raise Exception.CreateFmt('Invalid UPDATE_RULE "%s"', [VQuery.FieldByName('UPDATE_RULE').AsString]);
end;
end.
What is the current bug behavior?
Expected value "NO ACTION", get "NO ACTIO"
What is the expected (correct) behavior?
The value of the field must be "NO ACTION"