I want to know if there are any restriction to attribute names in amazons simpledb.
I tried the following attribute name
my.attribute.name
Running the following query
select * from mydomain where my.attribute.name is not null
results in an error: "The specified query expression syntax is not valid.".
Also surrounding 'my.attribute.name' results in an error because is invalid select syntax.
Changing point to underscore and everything works fine:
my_attribute_name
and the query runs fine
select * from mydomain where my_attribute_name is not null
Now my question: What are the allowed characters for attributes?
On the amazon developer manual the names are restricted to characters that are valid in xml documents. What exactly does this mean? The linked W3C documents seems not answering this. In domain names the dot "." is allowed.
Currently I use the sdbTool. I hope this doesnt affect the behaviour.
Inserting some other characters in attribute names is working, like this one: 'my:attribute-name.with other%20chars'.
Any ideas?
Can you please enclosed your attribute name in back-tick quotes and try again ?
Domain names & Attribute names need to be enclosed in back-tick quotes if they contains any special characters. Attribute and domain names may appear without quotes if they contain only letters, numbers, underscores (_), or dollar symbols ($). You must quote all other attribute and domain names with the back-tick (`) if they contains any special characters.
Related
I'm trying to list hyphenated criteria in a KDB WHERE IN list. The single (non-hyphenated) terms work just fine but when I need to have a hyphen in the literal, KDB doesn't like it. I've tried quoting the strings in a comma delimited list but that doesn't seem to work either.
This works just fine:
where product in (`CD`MUNICIPAL)
This gives me an error:
where product in (`TREASURY-NOTE`TREASURY-BOND`TREASURY-TIPS)
Error:
'TIPS
This is what I'm trying but with no luck:
where product in ("TREASURY-NOTE","TREASURY-BOND","TREASURY-TIPS")
Because "-" is a special character you need to declare these as strings before casting to symbols.
where product in `$("TREASURY-NOTE";"TREASURY-BOND";"TREASURY-TIPS")
You could also use "like" which allows you to use some basic regex:
where product like "TREASURY*"
I'm trying to do something like this
SELECT epi_week {week}, state
FROM
lookerdata:cdc.project_tycho_reports
LIMIT 10
Error: Encountered " "{" "{ "" at line 1, column 17. Was expecting: EOF>
It seems that curly braces are not legal syntax. I've tried escaping or using quotes without success.
Is there a way around this? We use the braces as an indication for post-processing string replacement to support multiple languages.
Is there a way around this?
No way unfortunatelly.
Field name must contain only letters, numbers, and underscores, start with a letter or underscore, and be at most 128 characters long.
As an option - you might want to come up with another name convention for post-processing
I need to create an XPath query to select a JCR node whose name contains a whitespace character.
For instance: /jcr:root/foo bar/
But that results in an invalid query.
How should whitespaces be encoded in an XPath query?
Try using something like this XPath query:
/jcr:root/foo_x0020_bar/
The JSR-170 (JCR 1.0) specification defines how XPath can be used to query a JCR repository, and even though JSR-283 (or JCR 2.0) deprecated XPath as a query language, many of the implementations still support XPath along with the other query languages (including the more powerful JCR-SQL2).
Now, regarding the rules for escaping characters in XPath, JSR-170 states the following in Section 6.6.4.9:
The names of elements and attributes (corresponding to nodes and properties, respectively) within an XPath statement must correspond to the form in which they (notionally) appear in the document view. This means that spaces (and any other non-XML characters) within names must be encoded according to the rules described in 6.4.3 Escaping of Names.
Section 6.4.3 defines how such characters are escaped in names:
The escape character is the underscore (“_”). Any invalid character is escaped as _xHHHH_, where HHHH is the four-digit hexadecimal UTF-16 code for the character. When producing escape sequences the implementation should use lowercase letters for the hex digits a-f. When unescaping, however, both upper and lowercase alphabetic hexadecimal characters must be recognized.
Although you didn't ask about it, you can easily do the same query in JCR-SQL2:
SELECT * FROM [nt:base] WHERE ISSAMENODE('/foo_x0020_bar')
I am trying to write a search that queries our directory server running openldap.
The users are going to be searching using the first or last name of the person they're interested in.
I found a problem with accented characters (like áéíóú), because first and last names are written in Spanish, so while the proper way is Pérez it can be written for the sake of the search as Perez, without the accent.
If I use '(cn=*Perez*)' I get only the non-accented results.
If I use '(cn=*Pérez*)' I get only accented results.
If I use '(cn=~Perez)' I get weird results (or at least nothing I can use, because while the results contain both Perez and Pérez ocurrences, I also get some results that apparently have nothing to do with the query...
In Spanish this happens quite a lot... be it lazyness, be it whatever you want to call it, the fact is that for this kind of thing people tend NOT to write the accents because it's assumend all these searches work with both options (I guess since Google allowes it, everybody assumes it's supposed to work that way).
Other than updating the database and removing all accents and trimming them on the query... can you think of another solution?
You have your ~ and = swapped above. It should be (cn~=Perez). I still don't know how well that will work. Soundex has always been strange. Since many attributes are multi-valued including cn you could store a second value on the attribute that has the extended characters converted to their base versions. You would at least have the original value to still go off of when you needed it. You could also get real fancy and prefix the converted value with something and use the valuesReturnFilter to filter it out from your results.
#Sample object
dn:cn=Pérez,ou=x,dc=y
cn:Pérez
cn:{stripped}Perez
sn:Pérez
#etc.
Then modify your query to use an or expression.
(|(cn=Pérez)(cn={stripped}Perez))
And you would include a valuesReturnFilter that looked like
(!(cn={stripped}*))
See RFC3876 http://www.networksorcery.com/enp/rfc/rfc3876.txt for details. The method for adding a request control varies by what platform/library you are using to access the directory.
Search filters ("queries") are specified by RFC2254.
Encoding:
RFC2254
actually requires filters (indirectly defined) to be an
OCTET STRING, i.e. ASCII 8-byte String:
AttributeValue is OCTET STRING,
MatchingRuleId
and AttributeDescription
are LDAPString, LDAPString is an OCTET STRING.
The standard on escaping: Use "<ASCII HEX NUMBER>" to replace special characters
(https://www.rfc-editor.org/rfc/rfc4515#page-4, examples https://www.rfc-editor.org/rfc/rfc4515#page-5).
Quote:
The <valueencoding> rule ensures that the entire filter string is a
valid UTF-8 string and provides that the octets that represent the
ASCII characters "*" (ASCII 0x2a), "(" (ASCII 0x28), ")" (ASCII
0x29), "\" (ASCII 0x5c), and NUL (ASCII 0x00) are
represented as a backslash "\" (ASCII 0x5c) followed by the two hexadecimal digits
representing the value of the encoded octet.
Additionally, you should probably replace all characters that semantically modify the filter (RFC 4515's grammar gives a list), and do a Regex replace of non-ASCII characters with wildcards (*) to be sure. This will also help you with characters like "é".
The convention for packages is your domain name. Dashes are sometimes not allowed in package names. So if your domain name has a dash what should you use?
The "official" convention in Java is to replace it with an underscore.
From (an older version of) the spec:
In some cases, the internet domain name may not be a valid package
name. Here are some suggested conventions for dealing with these
situations:
If the domain name contains a hyphen, or any other special character
not allowed in an identifier (§3.8), convert it into an underscore. If
any of the resulting package name components are keywords (§3.9) then
append underscore to them. If any of the resulting package name
components start with a digit, or any other character that is not
allowed as an initial character of an identifier, have an underscore
prefixed to the component.
Underscore is an option I've used before, but otherwise, just concatenate.