#2 mORMot 1 » Sample18-AJAX Extjs Grid ,Whether it is cross-domain? » 2014-06-06 07:08:28

畅雨
Replies: 2

The rest server run on port 8080, Html5 app run on port 8081 (MS IIS7),  Whether it is cross-domain?

\html5\app\store\contancts.js
...
actionMethods : {
							create : 'POST',
							read : 'GET',
							update : 'PUT',
							destroy : 'DELETE'
						},
						api : {
							create : 'http://localhost:8080/root/SampleRecord',
							read : 'http://localhost:8080/root/SampleRecord/?SELECT=*',
							update : 'http://localhost:8080/root/SampleRecord/',
							destroy : 'http://localhost:8080/root/SampleRecord/'
						},

...

About this,can tell us about it?

#4 Re: mORMot 1 » How can I build the params of ConnectionProperties.Execute() ? » 2014-05-27 06:52:22

sad    I do not know the number of parameters,Only know the number of parameters when running...  Need to dynamically create  parameters

#5 Re: mORMot 1 » TSQLDBStatement.FetchAllToJSON Missing first row of data ? » 2014-05-27 06:37:27

I use the Tquery with Pooling, and the connection is different,I want get query object form pool and set  conncetion

#6 mORMot 1 » How can I build the params of ConnectionProperties.Execute() ? » 2014-05-27 06:25:36

畅雨
Replies: 4

My code:

var
vparam: array of Tvarrec;
...
// How can I  build vparam ? the value form anther array (string array )

ConnectionProperties.Execute(aSQL, vparam)
...

#7 Re: mORMot 1 » TSQLDBStatement.FetchAllToJSON Missing first row of data ? » 2014-05-27 06:14:33

have a suggestion:
  Can Change  the Connection property of TQuery to read and write?
  property Connection: TSQLDBConnection read fConnection write fConnection;

#9 Re: mORMot 1 » TSQLDBStatement.FetchAllToJSON Missing first row of data ? » 2014-05-27 01:09:32

o~~,thanks!

But I need a  query of Parameter based on the name,and return json.  How I'm doing is the right ?

#10 mORMot 1 » TSQLDBStatement.FetchAllToJSON Missing first row of data ? » 2014-05-26 13:49:08

畅雨
Replies: 8

Test code  :

  ...
  VQuery:TQuery;
begin   
   VQuery:=TQuery.create(con);
   with VQuery do  
   begin   
      SQL.Clear;
      SQL.Add('select * from table');
      Open;
      Result:=PreparedSQLDBStatement.FetchAllAsJSON(aExpanded);
  end;
  ...

  There are 5 row of data in table , but only returns 4.

   In  SynDB  5440 line

  function TSQLDBStatement.FetchAllToJSON(JSON: TStream; Expanded: boolean;
  DoNotFletchBlobs: Boolean=false): PtrInt;
   ...  
            <-----------------  CurrentRow=1 ?
  // write rows data  
  while Step do begin
      ColumnsToJSON(W,DoNotFletchBlobs);
      W.Add(',');
      inc(result);
    end;
   ...

If I change the following:

    
 // write rows data
    //////////////////////////  畅雨 add begin 2014.05.26
    if CurrentRow=1 then
     begin
      ColumnsToJSON(W,DoNotFletchBlobs);
      W.Add(',');
      inc(result);
     end; 
    /////////////////////////// 畅雨 and end  2014.05.26
    while Step do begin
      ColumnsToJSON(W,DoNotFletchBlobs);
      W.Add(',');
      inc(result);
    end;

   
    THen Return 5 ,why?

#12 mORMot 1 » TQuery:Parameter '' not bound for '' ,has bug? » 2014-05-23 02:41:28

畅雨
Replies: 5

I  test like this:

 Q := TQuery.Create(aSQLDBConnection);
 try
      Q.SQL.Clear; // optional
      Q.SQL.Add('select * from TABLE');
      Q.SQL.Add('  WHERE ID_DETAIL=:detail;');
      Q.ParamByName('detail').AsString := '123420020100000430015';
      Q.Open;
      Q.First;    // optional
      while not Q.Eof do begin
          assert(Q.FieldByName('id_detail').AsString='123420020100000430015');
         Q.Next;
       end;
       Q.Close;   
   finally
       Q.Free;
 end;

----------------
raise error:Parameter 'detail' not bound for 'detail';

In SynDB.pas line  3397

 i := fParam.FindHashed(tmp);
    if i<0 then
      raise ESQLQueryException.CreateFmt('Parameter "%s" not bound for "%s"',[tmp,req]);

This statement  has bug?

#14 mORMot 1 » ConnectionProperties.GetTableNam return json result? » 2014-04-28 16:18:44

畅雨
Replies: 5

hi,
Current, GetTableNames  and  GetFieldNames  return result is RawUTF8Array,
Can  return json?

#15 Re: mORMot 1 » TOleDBConnection and multithread » 2013-11-03 01:47:52

My  test code (delphi7):

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,synoledb, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    MSSQL2012OLEDB:TOleDBMSSQL2012ConnectionProperties;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
   MSSQL2012OLEDB:=TOleDBMSSQL2012ConnectionProperties.Create('.','dh1pmip','sa','');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  MSSQL2012OLEDB.Execute('select 1 as  aa',[]);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  MSSQL2012OLEDB.Free;
end;

Click button1, run MSSQL2012OLEDB.Execute,   
When exit application, the process  can not be terminated.

#16 Re: mORMot 1 » TOleDBConnection and multithread » 2013-11-03 01:38:10

Oh,but ,not do it :(
     When exit application, sometime  the process  can not be terminated, sometime trancing to here:
---->
assert(OleDBCoinitialized>0,'You should call TOleDBConnection.Free from the same '+
    'thread which called its Create: i.e. call MyProps.EndCurrentThread from an '+
    'THttpServerGeneric.OnHttpThreadTerminate event - see ticket 213544b2f5');
  dec(OleDBCoinitialized);
  if OleDBCoinitialized=0 then
    CoUninitialize;

#17 Re: mORMot 1 » TOleDBConnection and multithread » 2013-11-02 15:29:04

ad,
       I do not use THttpServerGeneric ,only use olednconnection ,how can i  free it? sad
       help

     code:
        ...
        fDefaultConnectionProperties:=TOleDBMSSQL2012ConnectionProperties.Create('.','database','sa','');
        fDefaultConnectionProperties.Execute(sql,param);
        freeandnil(fDefaultConnectionProperties) ;
        .... 
       
     When exit application, the process  can not be terminated.

#19 Re: mORMot 1 » a little thinking about mORMot » 2013-10-27 07:46:58

My idea is that rest API is not the ORM, but the definition of sql. Each rest API is defined as the execution of a SQL, and the SQL parameter is passed, performed by the DB layer, returned the JSON result to client.

#20 Re: mORMot 1 » a little thinking about mORMot » 2013-10-27 07:40:28

ad,Thank you for your answer!

1. I have been using instantobject,want to switch to mORMot, instandobject using guid as objectid...
2. I do not use the ORM but  want to use SQL ans result as JSON,how to do it?

#21 mORMot 1 » a little thinking about mORMot » 2013-10-27 07:11:18

畅雨
Replies: 7

Some time after the test  :

1. Why is objectid not guid?  If guid should be more Suitable for distributed applications.
2. SQL Parameters used '?'    The SQL parameters are as follows: where  (name like @p1)  or (title like @P1)  or (desc like @p1),The parameters of processing need to write the same three, Why not use the parameter name?

#22 Re: mORMot 1 » mssql server2012 + syndbZEOS : If fieldname has some Asian languages( » 2013-10-25 12:26:35

SynDBZEOS.pas  line 548
  ...
      PSQLDBColumnProperty(fColumn.AddAndMakeUniqueName(StringToUTF8(name)))^.
  ...
replace as:
      PSQLDBColumnProperty(fColumn.AddAndMakeUniqueName(name))^.

  remove  StringToUTF8 , result is correct !
 
I guess Coding has been processed by zeos, the returned 'name' is UTF-8 encoded?

#25 mORMot 1 » mssql server2012 + syndbZEOS : If fieldname has some Asian languages( » 2013-10-25 08:35:32

畅雨
Replies: 7

Test : mssql server2012 + syndbZEOS : If fieldname has  some Asian languages(Double-byte characters) then error,
but oledb,firedac,sqlite3 is correct .

eg: SQL= select  'changyu畅雨' as 姓名   , the result : [{"濮撳悕":"changyu畅雨"}]      , remark: '姓名' = 'name'

The fieldname is wrong, but  fieldvalue is correct !   

 SynDBZEOS.pas  line 544
  ...
  for i := 1 to fResultInfo.GetColumnCount do begin
      name := (fResultInfo.GetColumnLabel(i));    -----maybe has error?
      if name='' then
        name := (fResultInfo.GetColumnName(i));  -----maybe has error?
  ...

But I do not know how to fix it   ...   sad

#26 mORMot 1 » mssql server2012 + syndbfireDAC:If fieldtype is boolean then error : C » 2013-10-25 03:23:52

畅雨
Replies: 1

Test : mssql server2012 + syndbfireDAC : If fieldtype is boolean then error : Cannot access field 'Booleanfield' as type Integer

synDBDataset.pas   line  584

Replace
 ...
 if ColumnValueDBType=IsTLargeIntField then
          WR.Add(TLargeintField(ColumnAttr).AsLargeInt) else
           WR.Add(TField(ColumnAttr).AsInteger); ----this error
...
as 
...
 if ColumnValueDBType=IsTLargeIntField then
          WR.Add(TLargeintField(ColumnAttr).AsLargeInt) else
          begin 
             if TField(ColumnAttr).DataType =ftBoolean then
              WR.Add(ord(TField(ColumnAttr).AsBoolean))   -------ok!
            else
              WR.Add(TField(ColumnAttr).AsInteger);
          end;
...

#28 Re: mORMot 1 » UTF8ToWideChar problem :do not support some Asian languages,eg:chinese » 2013-10-24 05:22:55

Problem solved, before Execute(SQL,[]) just AnsiToUtf8() :Execute(AnsiToUtf8(SQL),[])

#29 mORMot 1 » UTF8ToWideChar problem :do not support some Asian languages,eg:chinese » 2013-10-24 00:52:44

畅雨
Replies: 3

hi,ad

     I use synoledb, when SQL include some Asian languages(Double-byte characters),then  SQLW is Wrong. zeos,sqlite3,firedac has same problem.

-----> in synoledb.pas line 1480
  procedure TOleDBStatement.Prepare(const aSQL: RawUTF8;
  ExpectResults: Boolean);   
    begin

      ...
    SetLength(SQLW,L*2+1);
    UTF8ToWideChar(pointer(SQLW),pointer(fSQL),L); ----------------- this!
    fCommand.SetCommandText(DBGUID_DEFAULT,pointer(SQLW));

    end

    when fSQL  include some Asian languages(Double-byte characters),then  SQLW is Wrong.

   
   eg:
        fSQL ='select 'changyu畅雨'  as name '
        but  Converted to  SQLW ='select 'chan '

 ------->  symCommons   line  9432 
     function UTF8ToWideChar(dest: pWideChar; source: PUTF8Char; sourceBytes: PtrInt=0): PtrInt; 
       begin
          ...
       c := pCardinal(source)^;
       if (c and $80808080<>0)then    -------------not support some Asian languages(Double-byte characters)
              break; // break on first non ASCII quad
          ...     
       end

Board footer

Powered by FluxBB