Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:44:23+00:00 2026-06-02T18:44:23+00:00

Grails offers derived properties to generate a field from a SQL expression using the

  • 0

Grails offers derived properties to generate a field from a SQL expression using the formula mapping parameter:

static mapping = {
    myfield formula: "field1 + field2"
}

I’m trying to use the formula parameter with a PostgreSQL database to make a concatenated field. The syntax is a little strange since PostgreSQL 8.4 doesn’t yet support concat_ws:

static mapping = {
    myfield formula: "array_to_string(array[field1, field2],' ')"
}

The produced SQL shown with loggingSql = true in the DataSource config has the table prefix inserted into some strange places:

select table0_.field1 as field1_19_0_,
       table0_.field2 as field2_19_0_,=
       array_to_string(table0_.array[field1, table0_.field2], ' ') as formula0_0_
from test_table table0_ where table0_.id=?

The table prefix errantly appears before array but not before field1 in the derived formula. Is there a way to escape the prefix or correct this behavior more explicitly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:44:26+00:00Added an answer on June 2, 2026 at 6:44 pm

    This is just an issue with parsing the formula syntax. GORM tries to insert the table prefix for unquoted expressions not followed by parens, so the ARRAY[] notation trips it up.

    My solution was to define the concat_ws function:

    CREATE OR REPLACE FUNCTION concat_ws(separator text, variadic str text[])
    RETURNS text as $$
    SELECT array_to_string($2, $1);
    $$ LANGUAGE sql;
    

    The GORM formula parameter can now avoid the ARRAY[] syntax, and works as expected.

    myfield formula: "concat_ws(' ', field1, field2)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Grails 2.0.1 (upgraded from 1.3.7). In application.properties I have app.context = / and
Grails supports content negotiation from 3 different sources: Accept header Request parameter (format) URI
When using Grails 1.1 together with a MySQL the charsets of the auto-generated database
I am using a grails application as backend for a Flex frontend. To be
I'm considering using Grails for my current project. I have a couple of requirements
My Grails 2.0 app has a User domain object defined: class User { static
I would like to know what are the advantages and disadvantages of using Grails
Using Grails 2.0.0 I am created service, that creates instances of Player class and
Grails question: Confused about using a package to hold domain classes. I'm using Netbeans
using Grails 1.1.1 I have domain in Grails Person. Person can be related to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.