#1 2013-05-21 09:56:08

corchi72
Member
Registered: 2010-12-10
Posts: 232

Why I have error 405 from TSQLRecordMany.ManyAdd with old database?

Sorry if I insist but I have a problem with the generation of new tables by the framework in the sense that if I create a new database do not occur errors that occur instead if I upgrade an existing database.

The error is 405 and occurs when I run a simple code: AReport.Objects.ManyAdd(currentClient, AReport.id,Objects.id,True);

type
 

 TSQLObject = class(TSQLFile)
  private
    ...
  end;

 TSQLBaseReport = class(TSQLFile)  //new table
  private
  ...
  end;

 TSQLBaseReportObjects = class(TSQLRecordMany) //new table
  private
    fSource: TSQLBaseReport;
    fDest: TSQLObject;
  published
    property Source: TSQLBaseReport read fSource;
    property Dest: TSQLObject read fDest;

  end;

 TSQLReportObjects = class(TSQLBaseReportObjects); //new table

 TSQLReport = class(TSQLBaseReport )
  private
    fObjects: TSQLBaseReportObjects;
  public
...
  published
    property Objects: TSQLReportObjects read fObjects; 
  end;

//in the model I  declare only the classes [TSQLReportObjects ,TSQLReport ,TSQLObject] and not [TSQLBaseReportObjects, TSQLBaseReport]

procedure Test_ManyAdd_Object_to_Report;
var
   AReport :TSQLReport;
   AObject: TSQLObject;

begin

 AReport := TSQLReport.Create;
 AReport.Created := Iso8601Now;
 AReport.Modified := AReport.Created;
 currentClient.Add(AReport, true);

 AObject:= TSQLObject.Create;
 AObject.Created := Iso8601Now;
 AObject.Modified := AReport.Created;
 currentClient.Add(AObject, true);

 AReport.Objects.ManyAdd(currentClient, AReport.id,AObject.id,True); //Here the error occurs 405 with an old database created from the framework of months ago
end;

thanks corchi

Offline

#2 2013-05-21 12:29:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Why I have error 405 from TSQLRecordMany.ManyAdd with old database?

Created/Modified fields could be handled directly by the ORM using TCreateTime and TModTime kind of fields.
No need to set them with Iso8601Now by hand.

If you get an error 405, it means HTML_NOTALLOWED, that is you do not have write access to the corresponding tables.
You need to explicitly add the group access rights, when you add new tables to the model.
I suspect this is your problem.

Offline

#3 2013-05-21 12:43:30

corchi72
Member
Registered: 2010-12-10
Posts: 232

Re: Why I have error 405 from TSQLRecordMany.ManyAdd with old database?

I had understood that the tables were created from framerk if you do not exist, and so is done, I did not understand the rights of accesso.
Io run a server console and I connect with the client (user-synopse.) on the server side I don't declare ever the rights access.
I saw with the program SQLite2009 that the structure of the database,  and the only thing I notice is that I do not get created the row in the sqlite_sequence for "FastReportObjects"

Offline

#4 2013-05-21 12:52:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Why I have error 405 from TSQLRecordMany.ManyAdd with old database?

What is the TSQLAuthGroup content?

I suspect you did change the table order in the model, when adding new table.
This may have broken the table order in TSQLAuthGroup.AccessRights column.
For instance: AccessRights='0,1-9,12-256,0,0,0,0' will only give READ access to table 1-9,12-256.
If you add a TSQLRecord in the model in the 10 or 11 index, you won't have access to the table.

In short: new tables should be added at the end of the model!
Do not change the internal order of tables within a model.
It would break not only user rights, but also RecordReference fields.
This is AFAIR stated in the documentation.

Offline

#5 2013-05-21 14:11:38

corchi72
Member
Registered: 2010-12-10
Posts: 232

Re: Why I have error 405 from TSQLRecordMany.ManyAdd with old database?

You're right, I added the new tables in the list of tables in the model and not the tail should be done as.
Now I understand! Now I better read the documentation.

thanks corchi

Offline

#6 2013-05-21 14:18:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Why I have error 405 from TSQLRecordMany.ManyAdd with old database?

Sorry for not beeing clear enough in the doc.

Offline

Board footer

Powered by FluxBB