question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[3.0] Select all properties from table when joining

See original GitHub issue

In one query we are selecting a row in the model table based on some where conditions form a foreign table, thus we join the foreign key table. The primary key column name on that foreign table is the same as on the model table, so sometimes the wrong primary key was returned (the one of the foreign table row)

We worked around the issue by creating a similar property as Property.ALL_PROPERTY:

private Property<Pass> ALL_MODEL_PROPERTY = new Property(Model.class, "*") {

    @Override public String toString() {
      return FlowManager.getTableName(Model.class) + "." + getNameAlias().getAliasNameRaw();
    }
  };

This feels very hackish, so it would be nice to have a cleaner way to get such a property to only select all properties from a single table when joining multiple ones.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
trevjonezcommented, Oct 18, 2016

Here is a method that takes care of the ambiguous issue when it is a result of a join query.

@NonNull
static IProperty allFromTable(@NonNull Class<? extends Model> tableClass)
{
    require(tableClass).isNotNull();
    return new Property(tableClass, NameAlias.rawBuilder("*").build()).withTable();
}

Results in a query something like this:

SELECT `TABLENAME`.* FROM ...
1reaction
xanscalecommented, Aug 29, 2017

@trevjonez @agrosner I love you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select All columns for all tables in join + linq join
While you cant expand them to columns, you can simply return the entities. Eg: select new { CTLJCRJOB, CTLRFDSTM }.
Read more >
Getting All the Results When Joining with LINQ
When you want to find all the objects that are missing a corresponding object, then you need the LINQ equivalent of an outer...
Read more >
SQL joins and how to use them - Launch School
This type of join contains all of the rows from both of the tables. Where the join condition is met, the rows of...
Read more >
SQL JOIN TABLES: Working with Queries in SQL Server
In this article, you will see how to use different types of SQL JOIN tables queries to select data from two or more...
Read more >
Join tables and queries - Microsoft Support
In query Design view, double-click the join you want to change. · In the Join Properties dialog box, note the choices listed beside...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found