It's late, so this must be something stupid. I have LinqPad connected up to my database and cannot seem to get results for the simplest of queries.
var q = from app in AppInstances
select new {
AppId = app.AppId
};
When I run that, LinqPad says that it executed successfully (C#Statement mode). Nothing is retured.
I can write the following very simple Lambda (C# expression mode):
AppInstances.Select (p => p.AppId)
And that works. Why? I would prefer to use the non-lambda query building functionality. I am sure that this is something all together silly.
I would expect that in statement mode, you'd have to do something like call q.Dump(); to see the results.
But if you just want to use query expressions, why not do that from expression mode? Just use an expression of:
from app in AppInstances
select new {
AppId = app.AppId
};
Or to make it equivalent to your original lambda:
from app in AppInstances
select app.AppId
Related
I am trying to use ORMExecuteQuery. To do queries something like this:
ORMExecuteQuery("select count(*) from Customer");
This shows an error. So I have reduced the complexity of statement now to something smaller
// This works
rc.Customers = EntityLoad("Customer");
// This crashes
rc.Customers2 = ORMExecuteQuery("from Customer");
I have seen issues with ORMExecuteQuery() and the case of the object name.
Try using
ORMExecuteQuery("from customer");
I am trying to use an ordered, tagged hook using Java cucumber. For example:
#Before("#quicklink", order = 20)
The compiler doesn't seem to like it. Is it not possible to have an ordered, tagged hook ? Seems like a reasonable combination of functionality. If so, what is the syntax ?
thnx
I have tried the same but in a different way
#Before(value = "#quicklink", order = 20)
But, this may create odd issues if you have another hook method with the same order number for other tests. Like both the methods will run for this scenario.
So I suggest using the tagged expressions if you are using same order like as follows:
For other methods use
#Before(value = "~#quicklink", order = 20)
this will make sure this scenario will never run on other methods
and for this scenario alone,
#Before(value = "#quicklink", order = 20)
this will make sure the above method will never run for those.
If you are using 2x version of tagged expressions in your project, you can replace the '~' with a 'not'
This might come handy if you want to replace a method in hooks class in just a specific scenario.
#Before(value = "#quicklink", order = 20)
You should be able to specify the order for hooks like this:
Annotated method style (if you are using cucumber-java):
#Before(order = 10)
public void doSomething(){
// Do something before each scenario
}
Lambda style (if you are using cucumber-java8):
Before(10, () -> {
// Do something before each scenario
});
I am trying to avoid a sql injection. This topic has been dealt with in Java (How to prevent query injection on Google Big Query) and Php.
How is this accomplished in App Scripts? I did not find how to add a parameter to a SQL statement. Here is what I had hoped to do:
var sql = 'SELECT [row],etext,ftext FROM [hcd.hdctext] WHERE (REGEXP_MATCH(etext, esearch = ?) AND REGEXP_MATCH(ftext, fsearch = ?));';
var queryResults;
var resource = {
query: sql,
timeoutMs: 1000,
esearch='r"[^a-zA-z]comfortable"',
fsearch='r"[a-z,A-z]confortable"'
};
queryResults = BigQuery.Jobs.query(resource,projectNumber);
And then have esearch and fsearch filled in with the values (which could be set elsewhere).
That does not work, according to the doc.
Any suggestions on how to get a parameter in an SQL query? (I could not find a setString function...)
Thanks!
Unfortunately, BigQuery doesn't support this type of parameter substitution. It is on our list of features to consider, and I'll bump the priority since it seems like this is a common request.
The only suggestion that I can make in the mean time is that if you are building query strings by hand, you will need to make sure you escape them carefully (which is a non-trivial operation).
I'm trying to run a query against the ReleaseCumulativeFlowData object as follows:
((ReleaseObjectID = 12345) AND CardState="Accepted")
However, running the query results in the following error message:
OperationResultError
Could not read: could not read all instances of class
com.f4tech.slm.domain.reporting.ReleaseCumulativeFlowDataSet
Is this a bug in Rally?
WSAPI is very picky about the structure of the query. You have to include parentheses around chained query filters, so you would need something like the following:
((ReleaseObjectID = 12345) AND (CardState = "Accepted"))
If I were retrieving the data I wanted from a plain sql query, the following would suffice:
select * from stvterm where stvterm_code > TT_STUDENT.STU_GENERAL.F_Get_Current_term()
I have a grails domain set up correctly for this table, and I can run the following code successfully:
def a = SaturnStvterm.findAll("from SaturnStvterm as s where id > 201797") as JSON
a.render(response)
return false
In other words, I can hardcode in the results from the Oracle function and have the HQL run correctly, but it chokes any way that I can figure to try it with the function. I have read through some of the documentation on Hibernate about using procs and functions, but I'm having trouble making much sense of it. Can anyone give me a hint as to the proper way to handle this?
Also, since I think it is probably relevant, there aren't any synonyms in place that would allow the function to be called without qualifying it as schema.package.function(). I'm sure that'll make things more difficult. This is all for Grails 1.3.7, though I could use a later version if needed.
To call a function in HQL, the SQL dialect must be aware of it. You can add your function at runtime in BootStrap.groovy like this:
import org.hibernate.dialect.function.SQLFunctionTemplate
import org.hibernate.Hibernate
def dialect = applicationContext.sessionFactory.dialect
def getCurrentTerm = new SQLFunctionTemplate(Hibernate.INTEGER, "TT_STUDENT.STU_GENERAL.F_Get_Current_term()")
dialect.registerFunction('F_Get_Current_term', getCurrentTerm)
Once registered, you should be able to call the function in your queries:
def a = SaturnStvterm.findAll("from SaturnStvterm as s where id > TT_STUDENT.STU_GENERAL.F_Get_Current_term()")