SELECT_STMT ::=
SELECT_LIST ::=
FIELD_EXPR ::=
FIELD_SPEC ::=
ATTR_LIST ::=
The SELECT statement always returns a porcupine.core.objectSet.ObjectSet object. If select * is used then the returned object set iteration returns Porcupine objects, else the object set iteration returns dictionaries. If a Porcupine object does not have one of the selected attributes then None is returned. When selecting object datatypes the type of the returned values are:
Data type | Converted to |
---|---|
porcupine.datatypes.String | str |
porcupine.datatypes.Integer | int |
porcupine.datatypes.Float | float |
porcupine.datatypes.Boolean | bool |
porcupine.datatypes.Password | str |
porcupine.datatypes.Datetime | porcupine.datatypes.Datetime |
porcupine.datatypes.Date | porcupine.datatypes.Date |
porcupine.datatypes.Reference1 | porcupine.systemObjects.GenericItem |
porcupine.datatypes.ReferenceN | porcupine.core.objectSet.ObjectSet |
porcupine.datatypes.Relator1 | porcupine.systemObjects.GenericItem |
porcupine.systemObjects.RelatorN | porcupine.core.objectSet.ObjectSet |
porcupine.datatypes.Composition | porcupine.core.objectSet.ObjectSet |
porcupine.datatypes.Text | str |
porcupine.datatypes.File | str |
Sample queries:
Return all the objects' IDs and their display names only if they have a memberof attribute:
select id, displayName from deep('/') where memberof
Return the user objects contained inside the 'Users and Groups' container:
select * from 'users' where contentclass = 'schemas.org.innoscript.security.User'
Since the members attribute is an instance of the RelatorN type, the members.displayName is returned as a list of strings containing all the members' display names of each group:
select id, displayName, members.displayName from 'users' where members
Return all the containers IDs and how many children they contain:
select parentid, count(id) from deep('/') group by parentid
Search object descriptions for 'ser':
select id, displayName, description from deep('/') where 'ser' in description
Subqueries are supported since the 0.0.2 version. Select the group's ID, display name, and members whose name starts with 'a' only if the group has at least such a member:
select id, displayName, ( select * from this:members where slice(displayName,0,1) = 'a' ) as amembers from 'users' where len(amembers)>0