I'm not certain but I think there's a bug in Studio that is causing an
error with orient.getDatabase()
On Wednesday, June 3, 2015 at 1:32:40 PM UTC-7, hartmut bischoff wrote:
>
> Hi alltogether,
>
> is the feature of storing Funtions in the Database still usable?
>
> I followed documentation and got completely lost.
>
> First: I fired a simple SQL-Query
>
> Schema: contracts [n<-link->1] subcategories [n<-link->1] categories
> [n<-link->1] industries
>
> To query all contracts belonging to a single industry, (just as in a
> oldschool-sql-db) one can write
>
> select name categories.subcategories.contracts from Industries where
> name containstext 'ial'
>
> which obviously returns an Array :
>
> #<REST::Model::Myquery:0x00000003ffb880 @attributes={ "name" =>"Basic
> Materials", "categories"=>[["#21:1"]], "version"=>0, "cluster"=>"-2",
> "record"=>"0", "fieldTypes"=>"null=e", "created_at"=>2015-06-02 14:11:46
> +0200, "updated_at"=>2015-06-02 14:11:46 +0200}>
> #<REST::Model::Myquery:0x00000003ff9b20 @attributes={"name"=>"Financial",
> "categories"=>[["#21:2"]], "version"=>0, "cluster"=>"-2", "record"=>"1",
> "fieldTypes"=>"null=e", "created_at"=>2015-06-02 14:11:46 +0200,
> "updated_at"=>2015-06-02 14:11:46 +0200}>
> #<REST::Model::Myquery:0x00000003ff83b0 @attributes={"name"=>"Industrial",
> "categories"=>[["#23:0", "#23:1"]], "version"=>0, "cluster"=>"-2",
> "record"=>"2", "fieldTypes"=>"null=e", "created_at"=>2015-06-02 14:11:46
> +0200, "updated_at"=>2015-06-02 14:11:46 +0200}>
>
> So far, so good – the query is working perfect.
>
> Then I put the same query into a function:
> ( in Studio: )
> return orient.getDatabase().query("select name,
> categories.subcategories.contracts from Industries where name containstext
> 'ial'");
> and saved it as »getContracts«
>
> But when I tried to fetch the result via REST I got:
>
> uri: function/hc_database/getContracts
> {"result":[{"@type":"d","@version":0,"value":"orient.getDatabase().query(\"select
>
> name, categories.subcategories.contracts from Industries where name
> containstext 'ial'\")"}]}
>
> just the copy of the query-text....
>
>
> It turned better.
>
> I switched to javascript:
>
> var gdb = orient.getDatabase();
>
> return gdb.command( "sql", "select name ....
>
> ---> "code": 400,
> "reason": "Bad request",
> "content": "Error on parsing script at position #0: Error on
> execution of the script\nScript:
> allCategories\n------^\nsun.org.mozilla.javascript.WrappedException:
> Wrapped
> com.orientechnologies.orient.core.exception.OConfigurationException: No
> database instance found in context (<Unknown source>#10) in <Unknown
> source> at line number 10\nWrapped
> com.orientechnologies.orient.core.exception.OConfigurationException: No
> database instance found in context (<Unknown source>#10)\nNo database
> instance found in context"
>
> Ups.
>
> As only solution which works, I found
>
> language: Javascript
> Database-Instance by getGraphNoTx()
>
> To me the consequences of using getGraphNoTx are not clear. The strange
> behavior of the function-part should be noted as big bug in the
> development-Version .
> strange.
>
>
> (I am using the current stable 2.0 Version of OrientDB)
>
> Hartmut
>
--
---
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.