Hi, It seems something is not working anymore in the REST API. I've just pulled/built the develop branch, and now when I post to the /batch url, I get the following error :
2014-04-16 10:22:18:630 SEVE Internal server error: com.orientechnologies.orient.core.exception.ODatabaseException: Databaseinstance is not set in current thread. Assure to set it with: ODatabaseRecordThreadLocal.INSTANCE.set(db); [ONetworkProtocolHttpDb] On Tuesday, April 15, 2014 6:46:07 PM UTC+2, Lvc@ wrote: > > Hi, > fixed. The HTTP wrapper always returned the number of command executed. > > Lvc@ > > > > On 15 April 2014 18:20, Ivan Plaza <[email protected] <javascript:>> wrote: > >> Hi Pascal >> >> I actually got it working on my side. I had to download the latest >> snapshot by following the readme.txt (attached). >> >> After that the batch sql worked on the console and the binary protocol. I >> haven't tried the REST API though. >> >> I'm not familiar with the REST client side, but looking at your error it >> seems the sql query is not parsed correctly, there should be a return or >> semicolon between begin and the next statement: (sql.beginlet v = create >> vertex set Name='John'commitreturn $v) >> >> Try using semi colons between the statements and see if that helps. >> ["begin;let v = create vertex set Name='John';commit;return $v"] >> >> gluck >> >> >> >> >> On Monday, April 14, 2014 11:09:27 AM UTC-4, Pascal Le Quang wrote: >>> >>> Hi, >>> I'm experimenting the same problem as Ivan Plaza, using the REST api. >>> I'm using the develop branch, "freshly pulled" and built few hours ago. >>> If I post the following content to the /batch url >>> >>> { >>> "transaction": false, >>> "operations": [{ >>> "type": "script", >>> "language": "sql", >>> "script": ["begin", "let v = create vertex set Name='John'", >>> "commit", "return $v"] >>> }] >>> } >>> >>> I receive the following message : >>> >>> com.orientechnologies.orient.core.command.OCommandExecutorNo >>> tFoundException: Cannot find a command executor for the command request:sql >>> .beginlet v = create vertex set Name='John'commitreturn $v >>> >>> Instead of sending an array of sql commands, I've tried to send the >>> script with new line char between commands : >>> { >>> "transaction": false, >>> "operations": [{ >>> "type": "script", >>> "language": "sql", >>> "script": ["begin\nlet v = create vertex set >>> Name='John'\ncommit\nreturn $v"] >>> }] >>> } >>> >>> >>> then the response contains only the int value "1". I assume this is the >>> number of operations executed. But no new vertex has been created in the >>> database. >>> >>> And finally, if I've tried to send this >>> >>> { >>> "transaction": true, >>> "operations": [{ >>> "type": "script", >>> "language": "sql", >>> "script": ["let v = create vertex set Name='John'"] >>> }] >>> } >>> >>> >>> and a vertex is created, and I receive "1" as reponse. >>> >>> Am I doing something wrong when I send multiple statements ? >>> And is the "return" command working using the REST api ? >>> >>> Thanks >>> Pascal >>> >>> >>> >>> >>> >>> >>> On Sunday, April 6, 2014 11:52:35 PM UTC+2, Ivan Plaza wrote: >>>> >>>> Awesome! Is this available in 1.7 rc2? >>>> >>>> I'm getting the following error: com.orientechnologies.orient. >>>> core.command.OCommandExecutorNotFoundException: Cannot find a command >>>> executor for the command request: sql.begin >>>> >>>> >>>> On Saturday, April 5, 2014 4:08:26 PM UTC-4, Pawel K. wrote: >>>>> >>>>> Guys, >>>>> Do you see any reason why such sql batch, does NOT create >>>>> bidirectional link? >>>>> >>>>> begin >>>>> let var1 = INSERT INTO Address CONTENT {Town:"Wroclaw",Zip:0} >>>>> let var2 = INSERT INTO University CONTENT {Name:"Pwr"} >>>>> let var3 = UPDATE $var1 ADD in_EHasCorrespondenceAddress = $var2 >>>>> RETURN AFTER >>>>> let var3a = UPDATE $var2 ADD out_EHasCorrespondenceAddress = $var1 >>>>> RETURN AFTER >>>>> commit >>>>> return 1 >>>>> >>>>> It produces 2 records, but second does NOT have the link. When I >>>>> replace the ordering in the script always second created vertex has >>>>> missed >>>>> link. >>>>> >>>>> #18:0 v1 Address@Town:"Wroclaw",Zip:0,in_EHasCorrespondenceAddress:[# >>>>> 56:0] >>>>> #56:0 v1 University@Name:"Pwr" >>>>> >>>>> Thanks in advance >>>>> Pawel >>>>> >>>>> PS. I know that I can use CREATE EDGE in that case but for some reason >>>>> Im using provided case. >>>>> >>>>> On Friday, April 4, 2014 4:19:36 PM UTC+2, Lvc@ wrote: >>>>>> >>>>>> Hi Stefano, >>>>>> if you need a more complex language set "javascript" and use JS as >>>>>> language allowing more complex thing: https://github.com/ >>>>>> orientechnologies/orientdb/wiki/SQL-batch >>>>>> >>>>>> About rollback, if any exception occurs, the tx is automatically >>>>>> rollbacked. >>>>>> >>>>>> Lvc@ >>>>>> >>>>>> >>>>>> On 4 April 2014 16:02, Stefano Migliucci <[email protected]> wrote: >>>>>> >>>>>>> Hi, >>>>>>> how is possible to use "rollback" command? >>>>>>> Do we need something like IF, TRY/CATCH, etc? >>>>>>> Can you post an example? >>>>>>> >>>>>>> Stefano >>>>>>> >>>>>>> Il giorno lunedì 31 marzo 2014 20:46:31 UTC+2, Lvc@ ha scritto: >>>>>>> >>>>>>>> Hi all, >>>>>>>> OrientDB allowed to execute arbitrary script written in Javascript >>>>>>>> or any scripting language installed in the JVM. Well, starting from >>>>>>>> now we >>>>>>>> created a minimal SQL engine to allow batch of commands. >>>>>>>> >>>>>>>> Batch of commands are very useful when you have to execute multiple >>>>>>>> things at the server side avoiding the network roundtrip for each >>>>>>>> command. >>>>>>>> >>>>>>>> Example to create a new vertex in a transaction and attach it to an >>>>>>>> existent vertex by creating a new edge between them: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> *beginlet account = create vertex Account set name = 'Luke'let city >>>>>>>> = select from City where name = 'London'let edge = create edge Lives >>>>>>>> from >>>>>>>> $account to $city retry 100 commitreturn $edge* >>>>>>>> >>>>>>>> It's plain OrientDB SQL, but with few news: >>>>>>>> >>>>>>>> - *begin* -> begins a transaction >>>>>>>> - *rollback* -> rollbacks an active transaction >>>>>>>> - *commit* -> commits an active transaction >>>>>>>> - *let <variable> = <command>* -> executes a command and assign >>>>>>>> it in the context as . That variable can be used in further >>>>>>>> commands by >>>>>>>> prefixing it with $ >>>>>>>> - *return* <variable>|<value>|null -> returns a value instead >>>>>>>> of last command result (default >>>>>>>> >>>>>>>> Note also the usage of* $account *and* $city* on further SQL >>>>>>>> commands. >>>>>>>> >>>>>>>> *Java API* >>>>>>>> >>>>>>>> This can be used by Java API with: >>>>>>>> >>>>>>>> database.open("admin", "admin"); >>>>>>>> String cmd = "begin\n";cmd += "let a = create vertex set script = >>>>>>>> true\n";cmd += "let b = select from v limit 1\n";cmd += "let e = >>>>>>>> create edge from $a to $b retry 100\n";cmd += "commit\n";cmd += >>>>>>>> "return $e"; >>>>>>>> >>>>>>>> OIdentifiable edge = database.command(new OCommandScript("sql", >>>>>>>> cmd)).execute(); >>>>>>>> >>>>>>>> Remember to put one command per line (postfix it with \n). >>>>>>>> >>>>>>>> *HTTP REST API* >>>>>>>> >>>>>>>> And via HTTP REST interface (https://github.com/orientechn >>>>>>>> ologies/orientdb/issues/2056). Execute a POST against /batch URL >>>>>>>> by sending this payload: >>>>>>>> >>>>>>>> { "transaction" : true, >>>>>>>> "operations" : [ >>>>>>>> { >>>>>>>> "type" : "script", >>>>>>>> "language" : "sql", >>>>>>>> "script" : [ "let account = create vertex Account set name = >>>>>>>> 'Luke'", >>>>>>>> "let city =select from City where name = 'London'", >>>>>>>> "create edge Lives from $account to $city retry >>>>>>>> 100" ] >>>>>>>> } >>>>>>>> ]} >>>>>>>> >>>>>>>> >>>>>>>> Hope this new feature will simplify your development improving >>>>>>>> performance. >>>>>>>> >>>>>>>> What about having more complex constructs like IF, FOR, etc? If you >>>>>>>> need more complexity, I suggest you to use Javascript as language that >>>>>>>> already support all these concepts. >>>>>>>> >>>>>>>> Lvc@ >>>>>>>> >>>>>>>> >>>>>>>> PS: For more information look at issues -> https://github.com/ >>>>>>>> orientechnologies/orientdb/issues/2176 and https://github.com/ >>>>>>>> orientechnologies/orientdb/issues/2056 >>>>>>>> >>>>>>>> -- >>>>>>> >>>>>>> --- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "OrientDB" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>> send an email to [email protected]. >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "OrientDB" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
