Page 1 of 1

Formatting options for QBSelect

PostPosted: Wed Apr 10, 2024 10:47 am
by steve1376656734
In developer we can format our code using the Source -> Format menu (or a keycode combination). The way the code is formatted can be controlled using various options in the Developer settings in the Javascript -> Formatter section. I have set these so that when I format my code I get pretty much the layout I want but I cannot seem to control the way that a QBSelect is formatted.

I have the following code before the format:

Code: Select all
qMedias.where
   .add(qMedias.columns.tenant_name.eq(recTenant.tenant_name))
   .add(qMedias.columns.path.eq(path))
   .add(qMedias.columns.name.eq(docName))
   .add(qMedias.or
      .add(qMedias.columns.sha256.eq(sha256))
      .add(qMedias.columns.sha256.isNull));

I would very much like it to stay that way as I feel it makes the code more readable but when I format the code I end up with the whole statement on one line.

Code: Select all
qMedias.where.add(qMedias.columns.tenant_name.eq(recTenant.tenant_name)).add(qMedias.columns.path.eq(path)).add(qMedias.columns.name.eq(docName)).add(qMedias.or.add(qMedias.columns.sha256.eq(sha256)).add(qMedias.columns.sha256.isNull));


Are there any settings I can change that will allow the statement chaining to remain on separate lines?

TIA
Steve

Re: Formatting options for QBSelect

PostPosted: Wed Apr 10, 2024 12:03 pm
by Richard1521662995
+1

Re: Formatting options for QBSelect

PostPosted: Fri Apr 12, 2024 8:56 am
by huber
+1

Re: Formatting options for QBSelect

PostPosted: Fri Apr 12, 2024 12:08 pm
by steve1376656734
I have added a feature request for this here

Re: Formatting options for QBSelect

PostPosted: Fri Apr 12, 2024 3:53 pm
by gerardimmeker
You can add // to the end and start on a new line.
Then the formatter will skip the qbSelect

var qVehicles = datasources.db.autoflex_cloud.vehicles.createSelect();
qVehicles.where.add(//
qVehicles.and.add(//
qVehicles.or.add(//
qVehicles.columns.is_archived.isNull)//
.add(qVehicles.columns.is_archived.eq(0)))//
.add(qVehicles.columns.is_company_stock.eq(1)))//
.add(qVehicles.joins.vehicles_to_purchase_sales.columns.order_line_vehicle_sale_id.eq(null)//
);

Re: Formatting options for QBSelect

PostPosted: Fri Apr 12, 2024 6:10 pm
by steve1376656734
Great tip!

Thanks