You are not logged in.
Hi AB i startet SynDBExplorer with the Debugger and analyzed the Result from Rows.FetchAllAsJSON.
The JSON contains the wrong content in the Field.
May be the Error is in the Server - Code of SynDBRemote.
I'll try to debug this also.
Hi AB, sorry for the litte delay,
What do you call an "empty field"?
A column containing NULL?
In this case Empty means value = '' (Empty String, not null) dumped with sqlite3
In SynDBExplorer, what is the corresponding JSON?
where can i get this ?
In SynDBExplorer the Output looks like ToDataset
I forgot the Connection is made with the new SynDBRemote.
If i connect directly to the Database the trash is not shown.
ToDataset output:
ID UniqueID CreationDate LastEditDate Anzeigename Beschreibung KontaktID Logonname HashedPassword Verified Rechte
1 {6F454FFA-0C97-4780-BA69-6E98202B2B3E} 135201358696 135201358696 Administrator Automatisch angelegt beim Erstellen der Datenbank {6AEFDCD2-4A5F-469B-A1BB-E4B3949DFFB2} Admin 0b7fc485eb399bdde9e1c09cddceb2c396290dc23278831be4e242981d119ed3 1 7
2 {CC516404-53BC-4D4D-BC64-0B7E8A3DDA69} 135201386037 135201386037 My Name &{8E746F41-F824-4236-8D73-83A5CB8356BC}stefan@2a {8E746F41-F824-4236-8D73-83A5CB8356BC} My 2ad1b0748453272d8e73cbfe0869910b716d03f5bbd9da2d09849d6fa925aedf 0 0ToClientDataSet Output
ID UniqueID CreationDate LastEditDate Anzeigename Beschreibung KontaktID Logonname HashedPassword Verified Rechte
1 {6F454FFA-0C97-4780-BA69-6E98202B2B3E} 135201358696 135201358696 Administrator Automatisch angelegt beim Erstellen der Datenbank {6AEFDCD2-4A5F-469B-A1BB-E4B3949DFFB2} Admin 0b7fc485eb399bdde9e1c09cddceb2c396290dc23278831be4e242981d119ed3 1 7
2 {CC516404-53BC-4D4D-BC64-0B7E8A3DDA69} 135201386037 135201386037 My Name {8E746F41-F824-4236-8D73-83A5CB8356BC} My 2ad1b0748453272d8e73cbfe0869910b716d03f5bbd9da2d09849d6fa925aedf 0 0Hi AB,
i got the following DataSet Result
In DB there are 2 Records
the first has no Empty Fields, the second has some empty fields.
with ToDataset some of the Empty Fields of the second record are filled with memory - fragments
with toClientDataset they are empty as expected.
if you need more help ask pls.
Hi Arnoud,
is it possible to enhance SynDBExplorer to Connect to such a Remote Host ?
ATM i have to look at some tables on server without shutting it down.
So Remote DB access could solve the Problem.
Great Work Arnaud with this you made any supported SQL Database a single unique Network Interface
Esspecially SQLite
Hi AB you are right but there is a bug in the Wrapper code generating the Client Pas - Files.
The fields i defined on the Server where TCreateTime and TModTime, but the code generated by the Wrapper make them TTimeLog.
As Result the HasTimeFields in ComputeFieldsBeforeWrite is false and the Values are nil.
I modified the generated code to TCreateTime / TModTime by hand and it works !
Hi AB,
i create TSQLRecord on my Mobile Device and don't Know how to set TTimeLog there. (No SynCommons.pas available
)
Solved by mySelf !
Found in the Embarcadero Doku (http://docwiki.embarcadero.com/RADStudi … e/Methoden) that in class Functions the Self is defined as class of MyClass
so i pass Self to every CreateIndex and it works fine
I have 2 Ideas: the best would be it there exists something like "Self" Paramater for the ClassType (don't know if this exists in Delphi) an
pass it to
Server.CreateSQLMultiIndex("Self - Classtype", ['fIndexfield1'], false);
the second is more Complicated and enhance InitializeTable with the Parameter (Table : TSQLRecordClass)
class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions; Table: TSQLRecordClass = nil);
In CreateMissingTables you call the default Paramater (Table = nil)
In custom classes we hav to get rid of this Param
in the derived InitializeTable we have to add
class procedure TDerivedClass.InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions; Table: TSQLRecordClass);
begin
inherited InitializeTable(Server, FieldName, Options: TSQLInitializeTableOptions, TDerivedClass);
if (FieldName = '') or (FieldName = 'fIndexfield1') then
Server.CreateSQLMultiIndex(TDerivedClass, ['fIndexfield1'], false);
end;
and in Baseclass:
class procedure TBaseClass.InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions; Table: TSQLRecordClass);
begin
if assigned(Table) then begin
inherited (Server, FieldName, Options: TSQLInitializeTableOptions, Table);
if (FieldName = '') or (FieldName = 'ReferenceID') then
Server.CreateSQLMultiIndex(Table, ['ReferenceID'], false);
end else begin
inherited;
if (FieldName = '') or (FieldName = 'ReferenceID') then
Server.CreateSQLMultiIndex(TBaseClass, ['ReferenceID'], false);
end;
end;
Hi Arnoud i have the following Problem with InitializeTable:
suppose you have 2 TSQLRecord Classes :
class TBaseClass : TSQLRecord
..
fReferenceID : RawUtf8;
..
public
class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions); override;
...
and one derived Class:
class TDerivedClass : TBaseClass
..
fIndexfield1 : RawUtf8;
..
public
class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions); override;
...
class procedure TBaseClass.InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions);
begin
inherited;
if (FieldName = '') or (FieldName = 'ReferenceID') then
Server.CreateSQLMultiIndex(TBaseClass, ['ReferenceID'], false);
end;
class procedure TDerivedClass.InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions);
begin
inherited;
if (FieldName = '') or (FieldName = 'fIndexfield1') then
Server.CreateSQLMultiIndex(TDerivedClass, ['fIndexfield1'], false);
end;
If you call CreateMissingTables(0) an error occurs in TBaseClass.InitializeTable cause
Server.CreateSQLMultiIndex(TBaseClass, ['ReferenceID'], false); is called with TBaseClass and not with TDerivedClass.
I think that it has to be changed to pass TDerivedclass to the TBaseClass InitializeTable !
Hi AB, i found the place in the source where ViewTemplateFolder is initialized.
But i don't see the place where i can set this Parameter as i wan't
Can you please specify this in the Example.
Hi AB
cause of RawUTF8 Strings in used SynCommons.Pos in my code.
Under XE7 Win32 it is available but under Win64 not.
It depends on PurePascal which is wrong.
As a WorkAround i use SynCommons.PosEx(..,..,1) for Win64
tyvm with
Result := ServiceContext.Request.InHeader['Host'];i get what i want ![]()
Hi AB great work with MVC !!
Now i have a question :
How can I access the Ctxt.InHeaders from one of the MVCApplication Method like Default or Login ?
I want to use the Subdomain/Domain as Switch
Customer1.localhost -> Site for Customer1
Customer2.localhost -> Site for Customer2
Customer3.xxx -> Site for Customer3
In Default / Login i need the Value of the SubDomain.
tyvm - no it works
I get the following error requesting something from the wrapper:
{
"ErrorCode":500,
"ErrorText":"Exception ESynException: TTextWriter.AddVariantJSON(VType=16387)"
}Log-Entries:
20141021 18192424 + TSQLRestServerDB(0030CDD0).0059B624
20141021 18192424 call TSQLRestServerDB(0030CDD0) Wrapper
20141021 18192634 EXC ESynException ("TTextWriter.AddVariantJSON(VType=16387)") at 0052A477 stack trace API 0053C5D8 0040A900
20141021 18192636 srvr GET JobCloud/wrapper/CrossPlatform/mORMotClient.pas.txt ERROR=500 (Exception ESynException: TTextWriter.AddVariantJSON(VType=16387))
20141021 18192636 - 02.189.861Hi Ab, as i wrote here: http://synopse.info/forum/viewtopic.php?id=2065
i made this little Modification where i set SCOPE to LOCAL. May Be this does an error on the Linux MySQL - i'll try this out ans set Schema to the used Schema.
In all cases it is wrong not to set the Schema - Parameter in GetFields of UniDAC. If it is not set all Tables of the complete Database will be searched for fields.
ok - now i understand.
But back to my Error - Log
At
TSQLRestStorageExternal.Create(aClass: TSQLRecordClass; aServer: TSQLRestServer);
...
fProperties.GetFields(fTableName,fFieldsExternal);
...the GetFields seems to get no fields (REASON unknown atm)
the code goes into Create Table, were ExecuteDirect results in nil (cause of Create Table Exception)
if ExecuteDirect(pointer(SQL),[],[],false)<>nil then begin
fProperties.GetFields(fTableName,fFieldsExternal); // fields from DB after create
if fFieldsExternal=nil then
raise EORMException.CreateUTF8('%.Create: external table creation % failed:'+
' GetFields() returned nil - SQL="%"',[self,StoredClass,fTableName,SQL]);
end;no EORMException is raised. As Result Create Function tries no to create all Missing fields wich results in the next Exceptions.
I think we have to points now:
1. Why does Ubuntu MySQL 5.5 not return the Fieldlist of the Table ?
2. Why do you try to create Fields if Create Tables fails ![]()
I'll have a look at GetFields.
Hi i digged a little in CreateMissingTables and SynDBUniDac
the call of
fDB.GetTableNames(TableNamesAtCreation);in CreateMissingTables does not result in
TSQLDBUniDACConnectionProperties.GetTableNames
is this a bug ?
May be you are right,
first it want's to create a table which obviously exists. Then it want's to create a field which exists ...
But my Problem is connected to the other i postet.
What i saw in the source of mORMot, debugging CreateMissingTables is that the statement which selects the existing tables is written as SQLite Query.
'SELECT name FROM sqlite_master WHERE type=''table'' AND name NOT LIKE ''sqlite_%'';'Should SQLite Engine transfer this statement to a UniDAC GetTablenames Statement ? Or a MySQL Query to get Tablenames ?
We tried to install a service at a customer wich we testet and programmed on Windows MySQL 5.6
CreateMissingTables works as expected.
No we installed it at a customer and he has MySQL 5.5 on Linux
CreateMissingTables makes Errors:
1. it creates the Table in the Database
2. After Restart it can not find the former created Tables nor the fields in it.
here is some Log Output from the Linux Server
20141015 10585206 + TSQLDatabase(0288CD58).00AD13EA
20141015 10585206 SQL CREATE VIRTUAL TABLE kVASYAuftraegeRecord USING External(kVASy_AuftragID TEXT COLLATE SYSTEMNOCASE, TODO TEXT COLLATE SYSTEMNOCASE, Status TEXT COLLATE SYSTEMNOCASE, TSYSAufgabenID INTEGER, CreationDate TEXT COLLATE ISO8601, LastChangeDate TEXT COLLATE ISO8601);
20141015 10585206 + TSQLDBUniDACStatement(03235F60).00AC9EF1
20141015 10585206 + TSQLDBUniDACConnection(0288CD00).Connect to ProviderName=MySQL Database=manthey_turnus_schwerte on Server=192.168.101.231
20141015 10585206 DB Connected to MySQL (5.5.35-0ubuntu0.12.04.2)
20141015 10585206 - 00.001.373
20141015 10585206 - 00.001.464
20141015 10585206 + TSQLDBUniDACStatement(03235F60).00ACA045
20141015 10585206 SQL TSQLDBUniDACStatement(03235F60) SELECT NOW()
20141015 10585206 - 00.000.455
20141015 10585206 + TSQLDBUniDACStatement(032360E0).00AC9EF1
20141015 10585206 - 00.000.123
20141015 10585206 + TSQLDBUniDACStatement(032360E0).00ACA045
20141015 10585206 SQL TSQLDBUniDACStatement(032360E0) CREATE TABLE kVASYAuftraegeRecord (ID INT NOT NULL,kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE,TODO varchar(50) character set UTF8,Status varchar(50) character set UTF8,TSYSAufgabenID bigint,CreationDate datetime,LastChangeDate datetime, PRIMARY KEY(ID))
20141015 10585206 EXC EMySqlException ("\r\n#42S01Table 'kVASYAuftraegeRecord' already exists") at 008103D2 stack trace 00831ADF 00832212 0083225F 00687DAF 0083345A 00833526 0065543D 007F8888 006557D6 00655930 0040A2F7 0040A322 00ACD17C 00ACA1FA 00ABDAB8 00ABDACD 00ADA43C 00AD6903 00AE6067 00AE6294
20141015 10585206 EXC EMyError ("\r\n#42S01Table 'kVASYAuftraegeRecord' already exists") at 0082B6A8 stack trace API 00535998 0040B0D0 771CB46B 77180133 0082B6A8 0082D2AF 00832212 00687DAF 0065543D 006557D6 00ACD17C 00ADA43C 00AD6903 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF
20141015 10585206 EXC EMyError ("\r\n#42S01Table 'kVASYAuftraegeRecord' already exists") at 0082B6A8 stack trace API 00535998 0040B0D0 771CB46B 77180133 0082B6A8 0082D2AF 00832212 00687DAF 0065543D 006557D6 00ACD17C 00ADA43C 00AD6903 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF
20141015 10585206 EXC EMyError ("\r\n#42S01Table 'kVASYAuftraegeRecord' already exists") at 0082B6A8 stack trace API 00535998 0040B0D0 771CB46B 77180133 0082B6A8 0082D2AF 00832212 00687DAF 0065543D 006557D6 00ACD17C 00ADA43C 00AD6903 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF
20141015 10585207 EXC EUniError ("\r\n#42S01Table 'kVASYAuftraegeRecord' already exists") at 007F0FAC stack trace 00655930 0040A2F7 0040A322 00ACD17C 00ACA1FA 00ABDAB8 00ABDACD 00ADA43C 00AD6903 00AE6067 00AE6294 005174C6 008A5AB0 00AE6338 00406FAE 00AE0EF7 00406FAE 0040BD78 00ADFED6 00AE0F3D
20141015 10585207 EXC EUniError ("\r\n#42S01Table 'kVASYAuftraegeRecord' already exists") at 007F0FAC stack trace 00AD6903 00AE6067 00AE6294 005174C6 008A5AB0 00AE6338 00406FAE 00AE0EF7 00406FAE 0040BD78 00ADFED6 00AE0F3D 00B2B8BE 00B2BC5B 00B07125 00B2E763 00B0D794 00406FAE 00AE0EF7 00AE41D7
20141015 10585207 - 00.008.261
20141015 10585207 + TSQLDBUniDACStatement(032360E0).00AC9EF1
20141015 10585207 - 00.000.069
20141015 10585207 + TSQLDBUniDACStatement(032360E0).00ACA045
20141015 10585207 SQL TSQLDBUniDACStatement(032360E0) ALTER TABLE kVASYAuftraegeRecord ADD kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE
20141015 10585207 EXC EMySqlException ("\r\n#42S21Duplicate column name 'kVASy_AuftragID'") at 008103D2 stack trace 00831ADF 00832212 0083225F 00687DAF 0083345A 00833526 0065543D 007F8888 006557D6 00655930 0040A2F7 0040A322 00ACD17C 00ACA1FA 00ABDAB8 00ABDACD 00ADA43C 00AD6A70 00AE6067 00AE6294
20141015 10585207 EXC EMyError ("\r\n#42S21Duplicate column name 'kVASy_AuftragID'") at 0082B6A8 stack trace API 00535998 0040B0D0 771CB46B 77180133 0082B6A8 0082D2AF 00832212 00687DAF 0065543D 006557D6 00ACD17C 00ADA43C 00AD6A70 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF
20141015 10585207 EXC EMyError ("\r\n#42S21Duplicate column name 'kVASy_AuftragID'") at 0082B6A8 stack trace API 00535998 0040B0D0 771CB46B 77180133 0082B6A8 0082D2AF 00832212 00687DAF 0065543D 006557D6 00ACD17C 00ADA43C 00AD6A70 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF
20141015 10585207 EXC EMyError ("\r\n#42S21Duplicate column name 'kVASy_AuftragID'") at 0082B6A8 stack trace API 00535998 0040B0D0 771CB46B 77180133 0082B6A8 0082D2AF 00832212 00687DAF 0065543D 006557D6 00ACD17C 00ADA43C 00AD6A70 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF
20141015 10585207 EXC EUniError ("\r\n#42S21Duplicate column name 'kVASy_AuftragID'") at 007F0FAC stack trace 00655930 0040A2F7 0040A322 00ACD17C 00ACA1FA 00ABDAB8 00ABDACD 00ADA43C 00AD6A70 00AE6067 00AE6294 008A5AB0 00AE6338 00406FAE 00AE0EF7 00406FAE 0040BD78 00ADFED6 00AE0F3D 00B2B8BE
20141015 10585207 EXC EUniError ("\r\n#42S21Duplicate column name 'kVASy_AuftragID'") at 007F0FAC stack trace 00AD6A70 00AE6067 00AE6294 008A5AB0 00AE6338 00406FAE 00AE0EF7 00406FAE 0040BD78 00ADFED6 00AE0F3D 00B2B8BE 00B2BC5B 00B07125 00B2E763 00B0D794 00406FAE 00AE0EF7 00AE41D7 00AE498B
20141015 10585207 - 00.008.558
20141015 10585207 EXC EORMException ("TSQLRestStorageExternal.Create: TSQLkVASYAuftraegeRecord: unable to create external missing field kVASYAuftraegeRecord.kVASy_AuftragID - SQL=\"ALTER TABLE kVASYAuftraegeRecord ADD kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE\"") at 00AD6AFA stack trace API 00535998 0040B0D0 771CB46B 77180133 00AD6AFA 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF 00AD456A 00AD369D 00AD1423 00ADD135 00B51300 00B50F17 00B52479 00B54E5A
20141015 10585207 info TSQLRestStorageExternal.Destroy -> {"TSQLRestStorageExternal(02815EC0)":{}}
20141015 10585207 EXC EORMException ("TSQLRestStorageExternal.Create: TSQLkVASYAuftraegeRecord: unable to create external missing field kVASYAuftraegeRecord.kVASy_AuftragID - SQL=\"ALTER TABLE kVASYAuftraegeRecord ADD kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE\"") at 00AD6AFA stack trace API 00535998 0040B0D0 771CB46B 77180133 00AD6AFA 008A5AB0 00ADFED6 00B2B8BE 00B2BC5B 00B07125 00B004B9 00B005DF 00AD456A 00AD369D 00AD1423 00ADD135 00B51300 00B50F17 00B52479 00B54E5A
20141015 10585207 EXC EORMException ("TSQLRestStorageExternal.Create: TSQLkVASYAuftraegeRecord: unable to create external missing field kVASYAuftraegeRecord.kVASy_AuftragID - SQL=\"ALTER TABLE kVASYAuftraegeRecord ADD kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE\"") at 00AD6AFA stack trace 00AE0F3D 00B2B8BE 00B2BC5B 00B07125 00B2E763 00B0D794 00406FAE 00AE0EF7 00AE41D7 00AE498B 00AE0F69 00AE4FBE 00AFD090 00AFC9D6 00B0DA3B 00B0E589 00B09FFD 00AFD020 00AFCA58 00AE0F69
20141015 10585208 EXC ESQLite3Exception ("Error SQLITE_ERROR (1) - \"TSQLRestStorageExternal.Create: TSQLkVASYAuftraegeRecord: unable to create external missing field kVASYAuftraegeRecord.kVASy_AuftragID - SQL=\"ALTER TABLE kVASYAuftraegeRecord ADD kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE\"QUE\"\"") at 00AD4A6A stack trace 00B51300 00B51270 00B50F17 74E148A1 74E148A1 74E148A1 74E148A1 0052119A 00B52479 00B529AB 00B54E5A 00B5541B 0094BB7D 0094B7BC 0094BBF5 0095F6DB 0095F705 00956073 009560BB 004CE564
20141015 10585208 - 00.027.617
20141015 10585208 + TSQLDatabase(0288CD58).00AD13EA
20141015 10585208 SQL ROLLBACK TRANSACTION;
20141015 10585208 - 00.000.023
20141015 10585208 EXC ESQLite3Exception ("Error SQLITE_ERROR (1) - \"TSQLRestStorageExternal.Create: TSQLkVASYAuftraegeRecord: unable to create external missing field kVASYAuftraegeRecord.kVASy_AuftragID - SQL=\"ALTER TABLE kVASYAuftraegeRecord ADD kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE\"QUE\"\"") at 00AD4A6A stack trace API 00535998 0040B0D0 771CB46B 77180133 00AD4A6A 00AD369D 00AD1423 00ADD135 00B51300 00B50F17 00B52479 00B54E5A 00B5541B 0094B7BC 00956073 0040BC82 758C338A 771A9F72 771A9F45
20141015 10585208 + TSQLRestServerDB(027FC900).Shutdown
20141015 10585208 info CurrentRequestCount=0
20141015 10585209 - 00.010.712
20141015 10585209 info TSQLRestServerDB.Destroy -> {"TSQLRestServerDB(027FC900)":{"NoAJAXJSON":false,"HandleAuthentication":true,"StaticVirtualTableDirect":true}}
20141015 10585209 + 00AD23A0
20141015 10585209 - 00.000.015
20141015 10585209 EXC ESQLite3Exception ("Error SQLITE_ERROR (1) - \"TSQLRestStorageExternal.Create: TSQLkVASYAuftraegeRecord: unable to create external missing field kVASYAuftraegeRecord.kVASy_AuftragID - SQL=\"ALTER TABLE kVASYAuftraegeRecord ADD kVASy_AuftragID varchar(30) character set UTF8 NOT NULL UNIQUE\"QUE\"\"") at 00AD4A6A stack trace 0094BB7D 0094B7BC 0094BBF5 0095F6DB 0095F705 00956073 009560BB 004CE564 0040BC82 758C338A 771A9F72 771A9F45 our UniDAC Version is 5.5.12
I Implemented my Database as Global - Variable now and checked the Reconnect with mysql stop/start - works fine.
@Zeos I don't use Zeos cause i use UniDAC in all of my Projekts and know it well. In normal Projekts i don't thinks it's slow.
Do you know the Reason why UniDAC is slower as ZEOS ? It uses MySQL-Direct Interface to connect to MySQL.
Hi AB ty for your response.
we'll use DocVariantData now to Add Values. Cause we have to Add multiple Values to doc.fehler we have to call the AddValue direkt.
I havent't digged as deep as you in the RTL but would it be more Safe to remove the Pseudo - Functions ?
Solved the Problem with a cast:
DocVariantData(doc.fehler).AddValue('testfehler', true);I found something about pseudo methods in syncommons.pas - But it seem's not to work in release mode on XE7 ?!
Hi AB atm we encounter a serious(german: merkwürdig) Problem using TDocVariant
var
doc : variant;
begin
TDocVariant.New(doc);
doc.Fehler := _Obj([]);
doc.Fehler.Add('testfehler', true);
assert(doc.fehler.testfehler = true, 'Fehler mit TDocVariant');
end;On my developer Computer it works. Now we startet the programm in another computer and the assertion fails.
the Value of doc.fehler.testfehler is false
Very serious is that i get this error also sometimes in my debugger. But i didn't find the reason for this.
May you can help if you tell me how to debug it or where i have to set a breakpoint to inspect code.
Best Regards
Hi AB,
today i tried to optimize my Service which connects to a MySQL - Server with the following Statement
FModel := CreateModel;
FConnection := TSQLDBUniDACConnectionProperties.Create(TSQLDBUniDACConnectionProperties.URI(dMySQL,host + ':' + port), databasename, username, password);
VirtualTableExternalRegisterAll(FModel, fConnection);
FSQLDB := TSQLDatabase.Create(SQLITE_MEMORY_DATABASE_NAME, '');
FDatabase := TSQLRestServerDB.Create(FModel, FSQLDB, true);
FDatabase.CreateMissingTables(0);because it is a service which every 10 min works with the database, i disconnect it after i dont use it.
To increase Perfomance i wanted to call CreateMissingTables only at Servicestart and removed the above line.
In that way:
FModel := CreateModel;
FConnection := TSQLDBUniDACConnectionProperties.Create(TSQLDBUniDACConnectionProperties.URI(dMySQL,host + ':' + port), databasename, username, password);
VirtualTableExternalRegisterAll(FModel, fConnection);
FSQLDB := TSQLDatabase.Create(SQLITE_MEMORY_DATABASE_NAME, '');
FDatabase := TSQLRestServerDB.Create(FModel, FSQLDB, true);
if IsServiceStarted then
FDatabase.CreateMissingTables(0);And here is the Problem:
Now the Connection does not connect to MySQL any more !!!
Allthough FConnection points to a MySQL Database.
Now i think in CreateMissingTable is some code which connects the SQLite Engine with the MySQL one ?!
Line 350ff
SetLength(result, TField(ColumnAttr).DataSize);
// itSDS TField(ColumnAttr).GetData(pointer(result));
TField(ColumnAttr).GetData(TValueBuffer(result));Replace Pointer with TValueBuffer
line 706ff
if aArrayIndex>=0 then
{ itSDS
P.SetBlobData(pointer(VArray[aArrayIndex]),Length(VArray[aArrayIndex])) else
P.SetBlobData(pointer(VData),Length(VData));
}
P.SetBlobData(TValueBuffer(VArray[aArrayIndex]),Length(VArray[aArrayIndex])) else
P.SetBlobData(TValueBuffer(VData),Length(VData));
{$else}GetData and SetBlobData with Pointer as Param are deprecated
ATM i found a solution:
procedure TSQLDBUniDACConnectionProperties.GetFields(
const aTableName: RawUTF8; var Fields: TSQLDBColumnDefineDynArray);
...
if Table='' then begin
Table := Owner;
Owner := '';
end;
// if Owner = '' then
// Owner := MainConnection.Properties.DatabaseName;
meta.Restrictions.Values['SCOPE'] := 'LOCAL';
if Owner<>'' then
meta.Restrictions.Values['TABLE_SCHEMA'] := UTF8ToString(UpperCase(Owner));
meta.Restrictions.Values['TABLE_NAME'] := UTF8ToString(UpperCase(Table));
...Setting SCOPE to LOCAL forces UniDAC to set SCHEMA to DATABASE() (for MySQL - didn't test yet for other DB-Server)
The other Alternative is to set:
Owner := MainConnection.Properties.DatabaseName;
What do you think about it
Given : 1 MySQL Server with 2 Databases (Base1, Base2)
1. I connected my mORMot EXE to Base1 and called CreateMissingTables - Everything works fine
2. I connected my mORMot EXE to Base2 and called CreateMissingTables - Get Error Message: Table not found. This is correct, the Table is not in Base2 but in Base1.
After Some Debugging i found the Error:
You Call Metadata for 'columns' in UniDAC without giving the Schema name In my Case Base1 or Base2
The Result is that you retrieve the Columns from Base1
The Second Metadata you select is Indexes and here the Error comes with Table not found.
Can you fix this please.
Place of error (SynDBUniDAC):
meta := (MainConnection as TSQLDBUniDACConnection).fDatabase.CreateMetaData;
try
FA.Init(TypeInfo(TSQLDBColumnDefineDynArray),Fields,@n);
FA.Compare := SortDynArrayAnsiStringI; // FA.Find() case insensitive
FillChar(F,sizeof(F),0);
meta.MetaDataKind := 'Columns';
Split(aTableName,'.',Owner,Table);
if Table='' then begin
Table := Owner;
Owner := '';
end;
if Owner<>'' then
meta.Restrictions.Values['TABLE_SCHEMA'] := UTF8ToString(UpperCase(Owner));
meta.Restrictions.Values['TABLE_NAME'] := UTF8ToString(UpperCase(Table));
meta.Open;
hasSubType := meta.FindField('DATA_SUBTYPE')<>nil;
while not meta.Eof do beginOwner is not set (I don't know where i can set Owner ?). For MySQL the Owner is the databasename which i set to base1/base2
Just tested it and it works.
Hi ab,
i updated to UniDAC 5.5.11 yesterday and get an Error Message Connecting to MySQL.
In UniDAC there is a new Validation Function which checks the SpecificOptions if you add / modify any.
Server and Port is no valid Option for this.
so i Modified SynDBUniDAC.pas a little
constructor TSQLDBUniDACConnection.Create(aProperties: TSQLDBConnectionProperties);
var options: TStrings;
PortNumber : Integer;
begin
inherited Create(aProperties);
fDatabase := TUniConnection.Create(nil);
fDatabase.ProviderName := UTF8ToString(fProperties.ServerName);
case aProperties.DBMS of
dSQLite, dFirebird, dPostgreSQL, dMySQL, dDB2:
fDatabase.Database := UTF8ToString(fProperties.DatabaseName);
else
fDatabase.Server := UTF8ToString(fProperties.DatabaseName);
end;
options := (fProperties as TSQLDBUniDACConnectionProperties).fSpecificOptions;
if fDatabase.Server='' then // see TSQLDBUniDACConnectionProperties.URI()
fDatabase.Server := options.Values['Server'];
if fDatabase.Database='' then
fDatabase.Database := options.Values['Database'];
if (fDatabase.Port=0) and TryStrToInt(options.Values['Port'], PortNumber) then
fDatabase.Port := PortNumber;
fDatabase.Username := UTF8ToString(fProperties.UserID);
fDatabase.Password := UTF8ToString(fProperties.PassWord);
// BUGFIX s.d. UniDAC 5.5.11 Überprüft ungültige Parameter
// fDatabase.SpecificOptions.AddStrings(options);
end;I removed the last line cause Server and Port where the only Options.
Pls Check if there could be any unknown consequences i did not see.
Ticket created ![]()
atm i switched to RawUTF8(38) instead of TGUID
With this modification it works.
Hi AB,
atm i want to add a record to a table wich contains a TGUID stored AS_UNIQUE.
This is not possible with the CrossPlatform Client.
In SynCrossPlattformJSON.GetInstanceProp the Code for tkRecord is missing.
Pls Help
The Server reply is:
{
"ErrorCode":400,
"ErrorText":"Bad Request"
}IDEA:
May be i could have found my error easier if the error was not "bad request".
Is it possible to give error Messages like "unknown user", or "wrong password" ?
sry ab i found the Error: SetUser is case sensitive and i wrote user not User as username ![]()
Hi AB i tried to connect an universal firemonkey Client to one of my mORMot Servers but the connection was refused.
i found this article: http://synopse.info/forum/viewtopic.php?id=1976
it seems to have the same Problem.
Under normal Windows Client this code works to connect to the Server:
CompressShaAesSetKey('xyz');
FDatabase := TSQLHttpClient.Create(Server,APort,FModel);
FDatabase.Compression := [hcSynShaAes];
FDatabase.SetUser('User','synopse');on Server Side i register the Database with this code:
DB := TSQLRestServerDB.Create(Model,AppPath + 'database.db3',true);
AddToServerWrapperMethod(DB, ['..\..\..\CrossPlatform\templates']);
CompressShaAesSetKey('xyz');
Server := TSQLHttpServer.Create('5001',[DB],'+',useHttpApiRegisteringURI, 32, secSynShaAes);How can i connect to this Server with the generated code ?
atm i'm using:
Client := GetClient('myurl.url', 'user', 'synopse');Have i to remove the encryption on Server Side ?
I think best way would be to generate code which could connect automatically.
Hi AB,
yesterday i run TestSQL3 witn XE7 and it worked as in XE6
good work ![]()
I think this post is going into the wrong direction...
What i want to do with mORMot is to write a http - WebSite with login.
After Login every logged in user should see its specific data.
Simultaneous login from multiple clients should be possible.
For Login i dont want to create the wheel again and use TAuthUser/Group (or a derived class)
Is it possible you create a little sample http - WebServer(service) which shows this ?
It would show how to login with http and would show the mormot session handling.
Thank you very much
Sry for the delay, had to look in the sources...
Yes in low-level SynCrtSock as in Indy. If cookies are necessary i don't know. I only want to create support a self generated "web-site" and the mORMot functionality in one service-exe.
The web-site (delphi part) should connect to the database as the client which snchronises with the service-data.
Hi AB,
i have an Idea and want to know what you are thinking about it.
ATM i'm using IndyHttpServer für a little WebServer service. Now i'm enhancing this service with mORMot and think about replacing the IndyhttpServer Komponent with the mORMot one.
The only thing I'm missing is some Session Handling Stuff as in Indy.
ATM i create a Session Object in TIdHttpSession to store some Session Data.
Would it be interesting / Possible to include some Session Handling in mormot http server ?
Thank you Arnaud
can you please tell me which method to override where i can extend the select statement from the Clients ?
ATM I'm thinking about a Problem where i don't know exactly if mormot supports it or where i have to implement it.
I'm Starting with example Projekt 4 and add the Option to log in as different Users to the Client.
(Using : TSQLHttpClient(Form1.Database).SetUser('User','synopse');)
Now my wish is that every AuthUser has its own Data. I think adding a field UserID to SampleRecord would fullfill my needs.
Now my Problem / Question :
where on Server Side can i modify the Query to include "userid = authuser.id" ?
Test 1.4 Synopse PDF failed
Exception at
Check(Hash32(MS.Memory,MS.Position)=Hash[embed]); 1.4. Synopse PDF:
! - TPdfDocument: 1 / 4 FAILED 9.47s
- TPdfDocumentGDI: 8 assertions passed 1.57s
Total failed: 1 / 12 - Synopse PDF FAILED 11.05sThat was the clue, I set the PUBLISHRECORD OPtion an removed the InternalRegister... functions. Now it works.
No, atm only xe6 supports RTTI for TGUID.
I tried the code unter XE5 with InternalRegisterCustomProperties but InternalRegisterCustomProperties is not called before the RTTI is needed as i wrote in this thread on 21.5.2014
I tested TGUID - Custom Property again today. The Exception still exists.
I think there must something be changed in TSQLRecordProperties.Create
The function AddParentsFirst throws an Exception cause of the GUID - Field before the Function InternalRegisterCustomProperties is called.
In my opinion custom properties should be made available and then you should create the field - List.
Hopefully you understand what i mean smile
Hi AB testet the feature today with XE5 but got same error as on 24.4.2014 (XE6 is working perfect)