Server Connect with subtable returning incorrect data when a field has the same name in each

Wappler Version : 6.0.0 beta 13
Operating System : Windows 11
Server Model: node
Database Type: postgres
Hosting Type: n/a

Expected behavior

The correct value for the Contact table’s Type field should be returned.

In this example it should be “Contact”

This is the subtable’s related record showing its Type field set to “Default”

Instead it is returning “Default” for the Contact Type field

Here’s the subtable show its Type set to “Default” as well.
image

Actual behavior

The value from the Contact_email subtable’s Type field is returned in the Contact table’s Type field.

How to reproduce

  1. Create a table and subtable, each with a Type field.
  2. Setup an API to retrieve the Contact Table and its subtables.

Hey @kfawcett,

I don’t really understand what you are selecting here…

Please try:

  1. Remove Contact.*
  2. Remove all these Contact.Contact columns with different alias names
  3. You have to add one by one all the columns you need and when you add the Type column then set an alias “contType” for the Contact.Type or “contEmailType” for Contact_Email.Type

columns with the same name must have alias name set (different alias name for each matching table)

I usually prefix the columns of TABLE with something that points to the table they belong:
e.g.
Contact:
-cont_Email
-cont_Name
-cont_Type

Contact_Email:
-con_em_Email
-con_em_Name
-Con_em_Type

1 Like

Those are subtables of the contact table and that’s how Wappler adds them. What you’re suggesting seems like a workaround. I would prefer for the Wappler team to correct whatever is causing the default way of using the query builder to return the correct data.

image
image

Even if they are subtables of Contact table, their column name should appear like so when you add them…

*avoid having any kind of matching in names… Column names, subtable names…
Try using the prefix I told you my friend

I appreciate the suggestions. I just have a different opinion. Adding prefixes to table columns is redundant and unnecessary.

These subtables were created using Wappler’s Database Manager. While the actual table names are prefixed with the parent table’s name, they do not show in the UI. Wappler is smart enough to strip them out.

image

But, you led me down the right path. All I had to do was add an Alias to the Contact table.

This is probably what the Wappler team should ensure happens by default.

Now it’s returning the correct data, so thanks for the support @famousmag! :slight_smile:
image

2 Likes