different results for api request vs manual sql query in postgresql - postgresql

from the logs in my express server after a request from my front end:
Executing (default): SELECT "id", "associatedModelId", ... , "createdAt", "updatedAt" FROM
"Model" AS "Model" WHERE "Model"."otherModelId" = '11856';
console logging the result:
number of Models found: 0
yet if I cut and paste the same sql code into the psql console, I see the records I am looking for. Likewise, I get the correct results via a Postman request, using the same parameter.
Why can I not get the right outcome from the front end?

Related

SalesForce ADO.NET Source in SSDT 2013 SOQL Statement Using Date Literals Not Returning Results

I am having an issue with a date literal not returning any results when I run an SOQL query. The query is as follows:
Select * From dbo.Case WHERE CreatedDate = YESTERDAY
With the query, I would like to obtain case data from the previous day. I know there is data available that was created the previous day. The results of the query when I preview it, though, are an empty set with no error message.
A different wrinkle that makes this not quite a strict SOQL issue is that I am trying to use this query as an SQL command on an ADO.NET connection using the CData ADO.NET driver to connect to a SalesForce.com instance. My goal is to be able to build SSDT packages that will allow me to stage the data from SalesForce into our SQL Server for processing there.
I have similar issues using the LAST_N_DAYS date literal as well.
I believe I should be using SOQL to query in the SQL command text field for the ADO.NET source connection but I am not 100% sure about that. I know for certain that I cannot use T-SQL because it does not recognize the GETDATE().
Any guidance on how to pull the records from Case for the previous day or where the query I am using might be wrong would be greatly appreciated.
Found an answer. The following SQL command will pull the data from the previous day:
Select * From dbo.Case Where CreatedDate = 'YESTERDAY'
The single quotes evaluate the yesterday date literal as expected.
Likewise, the following SQL statement will get the last 30 days of data.
Select * From dbo.Case Where CreatedDate = 'LAST_N_DAYS:30'
Thanks to anyone who researched and attempted the question! :)

Executing the query using bq command line in Google Big Query

I execute a query using the below Python script and the table gets populated with 2,564,691 rows. When I run the same query using Google Big Query console, it returns 17,379,353 rows (query is as-is). I was wondering whether there is some issue with the below script. Not sure whether --replace in bq query replaces the past result set instead of appending to it.
Any help would be appreciated.
dateToday = (time.strftime("%Y/%m/%d"))
dateToday1 = dateToday.replace('/','')
commandStr = "type C:\Users\query.txt | bq query --allow_large_results --replace --destination_table table:dataset1_%s -n 1" %(dateToday1)
In the Web UI you can use Query History option to navigate to respective queries.
After you locate them - you can expand respective entries and see what exactly query was executed
I am more than sure that just comparing query texts you will see source of "discrepancy" right away!
added
In Query History - not only you can see Query Text, but also all configuration properties that were used for respective query - like Write Preference for example and others. So even if query text the same you can see potential difference in configuration that will give you a clue

Lesson 3 for MSDN error SQL Server Data Tools

i'm currently following this link and performing the steps
https://msdn.microsoft.com/en-us/library/ms170625.aspx
however, after importing in the Transact-SQL query, it tells me that
"Could not create a list of fields for the query. Verify that you connect to the data source and that your query syntax is correct. Query (7,24) Parser: The syntax for 'sp' is incorrect"
What could be the problem? I have tested connection of the database and it is connected. (and yes, the table exists in the database)

Not able to execute sql query with traverse in Orientdb restapi

I am new to OrientDB. I am trying to run the query "traverse * from #11:4 while $depth<=3" on the REST client (mentioned here). The query gives a valid graph with correct nodes when run on the local orientDB client. But gives the following error while trying to run the REST client.
Query,
http://localhost:2480/query/sample/sql/traverse * from #11:4 while $depth<=3
Response
com.orientechnologies.orient.core.exception.OQueryParsingException: Error on parsing query at position #8: Missed FROM
Query: traverse * from
-------------^
Can any of you highlight as to what is going wrong?
Did you escape # in your http call?
Seems like this problem
traverse * from
This is the query that arrive to OrientDb so i'm guessing it is a # problem
You can also use POST command instead of GET query so you can put the query in the body
see here
http://www.orientechnologies.com/docs/last/orientdb.wiki/OrientDB-REST.html#post---command

MapQuest Search API not yielding proper result

I have some data in MapQuest Data Manager v2 (DMv2) and I am trying to search this hosted data set using their search API(Web Service) but I am not getting desired results. Following are the snapshot of my data set and queries I am using :
These are the fields :
"storeid","brandname","onlineorderingenabled","street","zipcode","state","geocodereturncode","city","country","mqap_geography","mqap_quality","landmark","county","mqap_id","storename","longitude","latitude"
and this is sample row :
"1","Chili's","true","12815 Preston Rd","75230-1302","TX","","Dallas","US","POINT (-96.80363 32.92329)","P1AAA","","Dallas","ca6b6bae-945f-45fc-a8d1-3d512796150d","Preston/LBJ-Chili's","",""
Sample search queries :
http://www.mapquestapi.com/search/v2/search?key=[My_Key here]&shapePoints=-80,26&outFormat=json&hostedData=hostedData=mqap.121144_BrinkerStores|storename ILIKE ?|Preston/LBJ-Chili's|storeid,storename,city
http://www.mapquestapi.com/search/v2/radius?key=[My_Key]&origin=Dallas&inFormat=json&json={hostedData:[{tableName:mqap.121144_BrinkerStores,extraCriteria:City ILIKE ?,parameters:[Dallas],columnNames:[storeid,storename,city,state]}]}
I am not getting storedid,storenam,city,state. Please help me.
In the search/v2/search request, make sure your shapePoints are latititude,longitude and not the other way around. And the apostrophe in the storename needs to be double apostrophe'd for the postgres backend.
http://www.mapquestapi.com/search/v2/search?key=KEY&shapePoints=32.778149,-96.795403&hostedData=mqap.121144_BrinkerStores|storename=?|Knox-Chili%27%27s
In the search/v2/radius request, include the origin in the json and rename hostedData to hostedDataList.
www.mapquestapi.com/search/v2/radius?key=KEY&inFormat=json&json={"origin":"Dallas,TX","hostedDataList":[{"tableName":"mqap.121144_BrinkerStores","extraCriteria":"City ILIKE ?","parameters":["Dallas"],columnNames:["storeid","storename","city","state"]}]}