What does this xpath function mean? - postgresql

I'm trying to decode the URL characters such as "&amp" to "&", I found the code works in PostgreSQL - Replace HTML Entities
. The code is (xpath('/z/text()', ('<z>' || 'AT&T' || '</z>')::xml))[1] as output.
I try to understand this code and read the document of it, but the only thing I found is the explanation of xpath(xpath, xml [, nsarray]). I'm a freshman on PostgreSQL, and I know the /z/ is like a tag. But what is the "||","1" means? why should it use '/z/text()'.
If there have some links about that, it will very helpful. Thanks a lot.

Related

":Mi" has no value in the given object

select to_date(a.game_date|| ' ' ||a.game_time, 'yyyy-MM-dd HH24:Mi') as "beginTime", a.game_id "gameId"
one solution is here https://github.com/sequelize/sequelize/issues/7039, which is a good solution.
I am just wondering if there could be another solution to this issue using some escape syntax like E'foo'?
I tried using E'yyyy-MM-dd HH24:Mi' but didn't work
Edit: Adding more details here
I am calling postgres from nodejs not from the terminal. There the issue is not there. It might be related to how string is parsed here. Changing : to ||CHR(58)|| works perfectly.
to_char(to_timestamp(t/1000), 'YYYY-MM-DD"T"HH24:MI:SS"Z") is throwing the error ":Mi" has no value in the given object

TYPO3 queryBuilder: How to work with BINARY in where() clause?

I just have a short question.
There's no description in the following API overview of TYPO3 how to use a "BINARY" in where() clause: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Database/QueryBuilder/Index.html#expr
What I want to achieve? this one:
WEHRE BINARY `buyer_code` = "f#F67d";
Actually I can only do the following:
->where(
$queryBuilder->expr()->eq('buyer_code', 'f#F67d')
);
But in this case I don't get a satisfying result for myself because I need case-sensitive here :-)
An another buyer_code exists "f#F67D" (the last char is uppercase) but I do need to look for the other one.
Thanks for helping.
Since TYPO3 is using Doctrine API here, you could try to do
->where('BINARY `buyer_code` = ' . $queryBuilder->createNamedParameter('f#F67d'))
Please keep in mind, that this query now only works for database backends, supporting the BINARY keyword!
Please have a look at Doctrine2 case-sensitive query The thread is a bit older, but seems to cover background and solution for your problem.

how to replace < and in paylaod after data weave transform

I am trying to replace an xml from variable got from data weave into another data weave xml but I am getting xml with special chars as below, when the variable is replaced in the transform instead of getting '<' .
<pol:convictionCode>AC24</pol:convictionCode>
<pol:date>28012019</pol:date>
<pol:banLength>00</pol:banLength>
I am trying as below code but its not correct, getting error (org.mule.api.MessagingException: Execution of the expression).I also need to replace 
 with ''. Not sure how to replace both of them in one go. Highly appreciate any help.
payload.replaceAll("\\<","<")

Intuit.Ipp.Data.Qbo.CustomerQuery query with & in the name

How do you use Intuit.Ipp.Data.Qbo.CustomerQuery to query a name like:
Tom & Jerry's
This case has 2 special characters that are causing the query to fail. One being & and the other being '. I've tried to use Uri.EscapeDataString and it doesn't work. Any advice?
The SDK does not encode the ampersand correctly, so you will need to use DevDefined and deserialize the response with the SDK. Code sample: https://gist.github.com/IntuitDeveloperRelations/6024616
you would need to xml encode the string.
thanks
Jarred

whoosh doesn't search for short words like "C#"

i am using whoosh to index over 200,000 books. but i have encountered some problems with it.
the whoosh query parser returns NullQuery for words like "C#", "C++" with meta-characters in them and also for some other short words. this words are used in the title and body of some documents so i am not using keyword type for them. i guess the problem is in the analysis or query-parsing phase of searching or indexing but i can't touch my data blindly. can anyone help me to correct this issue. Tnx.
i fixed the problem by creating a StandardAnalyzer with a regex pattern that meets my requirements,here is the regex pattern:
'\w+[#+.\w]*'
this will make tokenizing of fields to be done successfully, and also the searching goes well.
but when i use queries like "some query++*" or "some##*" the parsed query will be a single Every query, just the '*'. also i found that this is not related to my analyzer and this is the Whoosh's default behavior. so here is my new question: is this behavior correct or it is a bug??
note: removing the WildcardPlugin from the query-parser solves this problem but i also need the WildcardPlugin.
now i am using the following code:
from whoosh.util import rcompile
#for matching words like: '.NET', 'C++' and 'C#'
word_pattern = rcompile('(\.|[\w]+)(\.?\w+|#|\+\+)*')
#i don't need words shorter that two characters so i don't change the minsize default
analyzer = analysis.StandardAnalyzer(expression=word_pattern)
... now in my schema:
...
title = fields.TEXT(analyzer=analyzer),
...
this will solve my first problem, yes. but the main problem is in searching. i don't want to let users to search using the Every query or *. but when i parse queries like C++* i end up an Every(*) query. i know that there is some problem but i can't figure out what it is.
I had the same issue and found out that StandardAnalyzer() uses minsize=2 by default. So in your schema, you have to tell it otherwise.
schema = whoosh.fields.Schema(
name = whoosh.fields.TEXT(stored=True, analyzer=whoosh.analysis.StandardAnalyzer(minsize=1)),
# ...
)