Skip to content

"SQL query" module and Postgre query: how to retrieve the user details stored in the DB using a "CustomUserSettings" Content Type? #15771

Answered by MarGraz
MarGraz asked this question in Q&A
Discussion options

You must be logged in to vote

@lampersky in the end, the problem was related to some syntax errors and the cast ::, as explained in the previous messages.

Now this query works because I have implemented a custom function to cast from text to jsonb:

SELECT 
    UI."DocumentId", 
    UI."UserId", 
    UI."NormalizedUserName", 
    UI."NormalizedEmail", 
    STRING_AGG(UBRNI.RoleName, ',') AS RoleNames,
    STRING_AGG(casttotext(UBRNID.UserByRoleNameIndexId), ',') AS RoleIds,
    jsonb_extract_path_text(cast_text_to_jsonb(D."Content"), 'Properties', 'UserDetails', 'UserDetails', 'Name', 'Text') AS FirstName,
    jsonb_extract_path_text(cast_text_to_jsonb(D."Content"), 'Properties', 'UserDetails', 'UserDetails', 'Surname', '

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@lampersky
Comment options

@MarGraz
Comment options

Comment options

You must be logged in to vote
5 replies
@MarGraz
Comment options

@MarGraz
Comment options

@MarGraz
Comment options

Answer selected by MarGraz
@sebastienros
Comment options

@MarGraz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants