Forum Replies Created
-
AuthorPosts
-
mrluigi2017
ParticipantHi Kim,
It looks like this one is reintroduced in version 5.21 (and still there in 5.22)
Kind regards,
Luigi
January 10, 2023 at 13:21 in reply to: ORM Update – Tablename gets quoted 3 times instead of 1 #56935mrluigi2017
ParticipantI have written al little test application and I noticed that the tripple quotes only appear when quotes are used when creating tables. Since this is a new project I have decided to use uppercase and no quotes for tables names (and other identifiers).
January 10, 2023 at 12:07 in reply to: ORM Update – Tablename gets quoted 3 times instead of 1 #56933mrluigi2017
ParticipantMessage removed.
-
This reply was modified 3 years, 10 months ago by
mrluigi2017.
January 10, 2023 at 09:30 in reply to: ORM Update – Tablename gets quoted 3 times instead of 1 #56932mrluigi2017
ParticipantThe connection pool is a TkbmMWUNIDACConnectionPool with a kbmMWInterbaseMetaData and a kbmMWInterbaseSQLRewriter.
mrluigi2017
ParticipantWe use Pascal case for our database including the sequences. I have change the sequences to upper case now 😀
mrluigi2017
ParticipantSorry that 🙁 I am using kbmMWHTTPSysServerTransport. I have tested it with kbmMWTCPServerTransport and kbmMWTCPIPIndyServerTransport and that seems to works fine.
mrluigi2017
ParticipantIt looks like that in unit kbmMWHTTPSysServerTransport (didn’t check other transports yet) on line 579 the status code that is set is overwritten by this line of code:
reshlp.HTTPStatusCode:=reshlp.HTTPStatusCodeFromServerStatusCode(res.StatusCode);
mrluigi2017
ParticipantIn Fiddler and Postman I still get a 200 status code instead of 201. Are you sure that this should work?
mrluigi2017
ParticipantHi Charles,
Some things you might want to check:
1) Do you have a MetaData component attached to the kbmMWMySQLRewriter?
2) Do you have a kbmMWMySQLRewriter attached to the kbmMWFiredacConnectionPool?
3) Does the table name in your entity match the table name in MySQL [kbmMW_Table(‘name:person’)]
4) Make sure that the meta data component properties like “quote table name” etc. match your situation.Kind regards,
Luigi
mrluigi2017
ParticipantDu er fantastisk 🙂
-
This reply was modified 5 years, 8 months ago by
mrluigi2017.
February 8, 2021 at 09:41 in reply to: ORM Standalone Demo project doesn’t compile in 5.12.10 and Delphi XE5 #55442mrluigi2017
ParticipantHi,
If I remember it well there where some serious issues in XE5 with generics which are heavily used in the ORM framework. I think you need XE7 or up.
-
This reply was modified 5 years, 9 months ago by
mrluigi2017.
mrluigi2017
ParticipantNever mind I found the solution.
var
qv: TkbmMWHTTPQueryValues; // kbmMWHTTPUtils
hlp: TkbmMWHTTPTransportStreamHelper;
s: string;
begin
qv := TkbmMWHTTPQueryValues.Create;
try
hlp := TkbmMWHTTPTransportStreamHelper(RequestTransportStream.Helper);
qv.AsString := hlp.Query; // Contains the part after the ?
s := qv.ValueByName[‘test’];…
mrluigi2017
ParticipantAre you sure this should work? I can’t get it working here.
-
This reply was modified 5 years, 9 months ago by
mrluigi2017.
mrluigi2017
ParticipantCould you log the SQL statement? I use Devart and they have a monitor tools which shows you all the SQL which is sent to the user. If not you could maybe use the kbmmw log function:
kbmMWDebugLevel := mwdlAll;
kbmMWDebugWhere := mwddDebug;
kbmMWDebugTypes := [mwdtDBQuery];It logs to the IDE messages window.
mrluigi2017
ParticipantJust forgot to add kbmmwOrm to the uses 🙂 The errr I got was “Class is missing kbmMW_table or virtual table attribute”.
mrluigi2017
ParticipantI am using enterprise 5.12.00 and both units are present. I think something went wrong with the setup.
mrluigi2017
ParticipantHi Kim,
It works 🙂 Just tested it with a 64GB file up and down.
It is true that I did not anticipate sending huge files (>2GB) back in the days.
I don’t blame you. It takes more than 31 weeks on a 28.8 modem 🙂
Thank you!!!
-
This reply was modified 6 years, 7 months ago by
mrluigi2017.
mrluigi2017
ParticipantWhat exactly do you mean? You can set the blocksize in the kbmMWFileClient. I haven’t figured out yet howto deal with the filesize issue.
mrluigi2017
ParticipantHi Job,
There is a demo that contains brief cases. Not sure if it works or not. It can be found in the demo folder:
kbmmw\Demo\Basic\Client
Kind regards,
Luigi
mrluigi2017
ParticipantThe slow transfer issue is solved. I have changed the chunksize to 1048576 and the speed is good now. There is however still an issue with downloading a large file. See the code in the second post. Uploading large files (larger than max int) doesn’t seem to be a problem.
mrluigi2017
ParticipantI also have an issue that the transfer is very, very slow. I think I am doing something wrong, but I have no clue what it is.
mrluigi2017
ParticipantI figured out that downloading a large file doesn’t work either. I think the cause is that an int 64 is assigned to an VarArray with varIntegers.
function TkbmMWFileService.PerformGET
Result:=VarArrayCreate([0,2],varInteger);
// Prepare result.
Result[0]:=FFileToken;
Result[1]:=ofs; //is an int64
Result[2]:=sz; // is an int64Although I didn’t find anything for my upload problem I suspect it could be the same type of issue.
mrluigi2017
ParticipantI had some issues with the ImportDBSchema as well so I wrote my own tool for Postgres databases. I am not sure if the import tool is fixed by now.
I have used the kbmMWInterbaseSQLRewriter and it worked for me. It’s also important to connect a kbmMWInterbaseMetaData component to the Rewriter component. The metadata component takes care about things like uppercase/lowercase, the use of quotes, date layout, etc.
I supspect that you didn’t build for 64 bit or that you forgot to set the correct paths.
mrluigi2017
ParticipantHi Alexander,
As far as I know there is no specific documentation on the rewriter. The rewriter is needed when you use the ORM. It rewrites the SQL to match your target database requirements. It compiles on Win64 here without a problem (I am using enterprise) What version do you use? And what error do you get?
mrluigi2017
ParticipantNever mind. I am just a moron 🙁 The dataset was empty
mrluigi2017
ParticipantI think it’s not a bug. I will open a new topic.
mrluigi2017
ParticipantAny change that there is a bug in the ListFromDataset method as well?
mrluigi2017
ParticipantIt seem that in the destructor all the objects used in the add record method a freed, but that is not the case. For instance a1 is used as a reference for 3 different objects and only 1 of them is freed in the destructor.
mrluigi2017
ParticipantYou could use the orm for this. I wrote a little very basic demo. I used firedac as a connection but you can change this. You need to setup the firedac connection before you can use it. (Make a test database for it!) In the demo you have to take care of the primary key(message_id) yourself.
Here is a link to the code:
https://lycaproductions.stackstorage.com/s/5L82VjorZ4ylSNC
is valid till 31-08-2019
Here the code itself:
unit f_main;
interface
uses
kbmMWOrm,
kbmMWNullable,
kbmMWRtti,Data.DB,
Generics.Collections,
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
kbmMWCustomConnectionPool,
kbmMWFireDAC,
kbmMemTable,
Vcl.ExtCtrls,
Vcl.DBCtrls,
Vcl.Grids,
Vcl.DBGrids,
Vcl.StdCtrls,
kbmMemCSVStreamFormat,
FireDAC.Stan.Intf,
FireDAC.Stan.Option,
FireDAC.Stan.Error,
FireDAC.UI.Intf,
FireDAC.Phys.Intf,
FireDAC.Stan.Def,
FireDAC.Stan.Pool,
FireDAC.Stan.Async,
FireDAC.Phys,
FireDAC.Phys.FB,
FireDAC.Phys.FBDef,
FireDAC.VCLUI.Wait,
FireDAC.Comp.Client,
kbmMWSQLRewriter,
kbmMWCustomSQLMetaData,
kbmMWInterbaseMetaData;type
TForm1 = class(TForm)
kbmMWFireDACConnectionPool: TkbmMWFireDACConnectionPool;
// Notice that the kbmCSVStreamFormat is set to the AllDataFormat property
mtMessages: TkbmMemTable;
dsMessages: TDataSource;
DBNavigator: TDBNavigator;
grdMessages: TDBGrid;
btnSaveToFile: TButton;
btnSaveToFireBird: TButton;
kbmCSVStreamFormat: TkbmCSVStreamFormat;
btnOpenFromFile: TButton;
btnOpenFromFireBird: TButton;
FDConnection: TFDConnection;
mtMessagesmessage_id: TIntegerField;
mtMessagesmessage_text: TStringField;
btnOpen: TButton;
btnCreateTable: TButton;
kbmMWInterbaseMetaData: TkbmMWInterbaseMetaData;
kbmMWInterbaseSQLRewriter: TkbmMWInterbaseSQLRewriter;
procedure btnCreateTableClick(Sender: TObject);
procedure btnOpenClick(Sender: TObject);
procedure btnOpenFromFileClick(Sender: TObject);
procedure btnSaveToFileClick(Sender: TObject);
procedure btnSaveToFireBirdClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
Orm: TkbmMWORM;
public
procedure SaveMessageMemoryTableToFile;
procedure SaveMessageMemoryTableToFireBird;procedure LoadMessagesFromFile;
procedure LoadMessageFromFireBird;
end;[kbmMW_Table(‘name:my_messages’)]
TMyMessage = class
private
FMessageID: kbmMWNullable<Integer>;
FMessageText: kbmMWNullable<string>;
public
[kbmMW_Field(‘name:message_id, primary:true’, ftInteger)]
property MessageID: kbmMWNullable<Integer> read FMessageID write FMessageID;[kbmMW_Field(‘name:message_text’, ftString)]
property MessageText: kbmMWNullable<string> read FMessageText write FMessageText;
end;var
Form1: TForm1;implementation
{$R *.dfm}
procedure TForm1.btnCreateTableClick(Sender: TObject);
begin
if not Orm.ExistsTable(TMyMessage) then
beginif Orm.CreateTable(TMyMessage) then
ShowMessage(‘TMyMessage Table Created’)
else
ShowMessage(‘Error creating table’);end;
end;procedure TForm1.btnOpenClick(Sender: TObject);
begin
mtMessages.Open;
end;procedure TForm1.btnOpenFromFileClick(Sender: TObject);
begin
LoadMessagesFromFile;
end;procedure TForm1.btnSaveToFileClick(Sender: TObject);
begin
SaveMessageMemoryTableToFile;
end;procedure TForm1.btnSaveToFireBirdClick(Sender: TObject);
begin
SaveMessageMemoryTableToFireBird;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
// You can change the connection pool to the one you like.
// Before you can persist to the database,
// you have to make sure that the connection pool is setup.
Orm := TkbmMWORM.Create(kbmMWFireDACConnectionPool);
end;procedure TForm1.LoadMessageFromFireBird;
var
MessageList: TObjectList<TMyMessage>;
begin
MessageList := Orm.QueryList<TMyMessage>;
Orm.ToDataset<TMyMessage>(MessageList, True);
end;procedure TForm1.LoadMessagesFromFile;
begin
mtMessages.LoadFromFileViaFormat(‘.\MyMessagFile.csv’, kbmCSVStreamFormat);
end;procedure TForm1.SaveMessageMemoryTableToFile;
begin
mtMessages.SaveToFileViaFormat(‘.\MyMessagFile.csv’, kbmCSVStreamFormat);
end;procedure TForm1.SaveMessageMemoryTableToFireBird;
var
MessageList: TObjectList<TMyMessage>;
begin
MessageList := Orm.ListFromDataset<TMyMessage>(mtMessages, [usModified, usInserted, usDeleted]);
Orm.Persist(MessageList);
end;initialization
TkbmMWRTTI.EnableRTTI([TMyMessage, TObjectList<TMyMessage>]);
kbmMWRegisterKnownClasses([TMyMessage, TObjectList<TMyMessage>]);end.
-
This reply was modified 7 years, 3 months ago by
mrluigi2017.
mrluigi2017
ParticipantI guess it’s bedtime for me 🙂 Thank you!
mrluigi2017
ParticipantMin tak er stor! Only now do I realize how powerful smartbinding is. It makes life a lot easier.
-
This reply was modified 7 years, 3 months ago by
mrluigi2017.
mrluigi2017
ParticipantDid you do a license request in the portal?
mrluigi2017
ParticipantThe main issue was that the fields where created dynamically . I now have to separate methods one for REST clients and one for kbmmw clients. I also have two different result objects. The REST result object still marshals the memtable (no issues with this) I have replaced the memtable for a stream in the kbmmw result object and added a property with a getter that loads the stream into a memtable. This way the memtable never gets marshalled
Maybe this solution is usefull to others.
mrluigi2017
ParticipantNever mind I did something very stupid 🙁
I had a dbaware control connected to a DataSource->kbmMemTable with a wrong datafield value in it. So the ToDataset method works fine but when it opens it goes wrong because of the wrong datafield. I should have known it wasn’t kbmmw 🙂 Sorry!
-
This reply was modified 7 years, 5 months ago by
mrluigi2017.
-
This reply was modified 7 years, 5 months ago by
mrluigi2017.
mrluigi2017
ParticipantYes I did. Not sure if it’s important but the ToDataset method is not in the same unit as where I call the smartclient function returning the object that is used in the ToDataset method.
mrluigi2017
ParticipantThat would be nice because in combination with the orm many objects will have nullable properties I think.
mrluigi2017
ParticipantI forgive you and I still love you 😉 You’re just working to hard 🙂
mrluigi2017
ParticipantAre you 1000% sure? I have download 7.82 again just to be sure. But the kbmMemTable.pas shows
const KBMMEMTABLE_VERSION = ‘7.81.00’;
The fix comments in the same unit stop at version 7.81. as well.
mrluigi2017
ParticipantSupercool 🙂 Can’t wait to try it out.
mrluigi2017
ParticipantMost ORM frameworks I know use some kind of dataset between the GUI and the logic. Can the same be accomplished in kbmmw if you twoway smartbind a memtable to a TObjectList/TObject?
-
This reply was modified 7 years, 6 months ago by
mrluigi2017.
mrluigi2017
ParticipantIm not sure exactly what you are asking.
I was afraid for that 🙂 One more try…
When you use datasets and data-aware controls the data-aware controls change from editable to non editable states depending on the state of the dataset dsEdit, dsBrowse etc. The dbnavigator enables only relevant buttons.This works very easy. I wonder if the same enabling/disabling of input controls can be accomplished with smartbinding and non dataset objects in an easy way.
-
This reply was modified 7 years, 6 months ago by
mrluigi2017.
mrluigi2017
ParticipantHi Francisco,
I think I used that construction before, but it gave some issues (not sure anymore what it was). I didn’t have time to dive into it, but I think something has changed between te previous release I used an this one.
mrluigi2017
ParticipantI am not sure if I understand you correctly. Are you saying that just the visual output of a null value is zero (in case of an integer) or that the value will be zero? When reading my postgres logs I think it’s the second, but that doesn’t make sense to me because both JSON an the database can take care of null.
mrluigi2017
ParticipantWell the thing is that you make it to easy so we get a little lazy 😉
mrluigi2017
ParticipantThanks for both answers! It would be nice feature if there wouldn’t be a need to write the kbmmw syntax.
-
This reply was modified 7 years, 7 months ago by
kimbomadsen.
mrluigi2017
ParticipantI have added the one line of code and it works 🙂
Not sure if this is a general solution or just for kbmMWUnidac and PostgreSQL. I think it is a general solution because I believe that transactions should be only controlled from within the kbmmw framework.
I have added this line of code in the InternalOpenConnection method.
FDatabase.AutoCommit := False; // Is true by default in UniConnection
mrluigi2017
ParticipantI did some testing with kbmmwFiredac yesterday and it works fine. I think you are right that it has to do with transaction settings. I don’t want to blame kbmmw 🙂 but could it be that in the unidac adapter InternalOpenConnection method some connection properties are not set? Am I right that if a property isn’t set here the default value is used?
Thanks in advance!
mrluigi2017
ParticipantHow about ORM and Postgres? Will it work if I create a generator with a sequence or will the problem be the same behind the scenes?
mrluigi2017
ParticipantWhat I try to accomplish is that I can resolve a join with ORM and that I can show the join (virtual table) as one dataset. Is there an easy way to do that?
The only solution I see now is that in case of a TPerson with a TAddress is to add all TAddress properties as virtual fields to a TPersonWithAddress object and create a TAddress object and copy the values from the virtual addresss fields from TPersonWithAddress before persisting. (That’s an ugly sentence 🙂 )
mrluigi2017
ParticipantI looks like the mime type var never makes it to the UmarshalBody method in kbmMWSmartServiceUtils.
My http header looks like this:
User-Agent: Fiddler
Mime-Type: application/json
Host: 192.168.0.56
Content-Length: 39Am I doing something wrong or is this a bug?
-
This reply was modified 3 years, 10 months ago by
-
AuthorPosts
