- Issue created by @adpo
- π«π·France guignonv
Hi! First, I don't really understand what you are trying to achieve. :-s I'm missing some context or details.
...but I'll try to provide an answer from what I got. :)First, you may just need xnttviews β module. If you didn't try it, it may just do what you need. And, by the way, if you'd like to contribute to that module, your help would be appreciated.
If you're trying to join external database tables using views feature, I doubt it's possible or simple. When you create an external entity, regardless of what's behind (ie. a REST service, an xnttdb, an xnttfiles, etc.), it's considered by Drupal as a content entity. As far as I got it, views module was initially designed to work with SQL content entity (a sub-class of content entities) but it has been modified to be able to handle other types of content entities through plugins. It may be what you are talking about and trying to do...
On one hand, you would need to know that the external entity uses the xnttdb plugin when you edit your view (while the storage plugin can be changed after the view is created, leading to errors) and on the other hand, the problem is that I don't see any easy way to modify an xnttdb SQL query to add joins. The "joins" must be made another way, like if you are trying to "join" 2 types of entities that are not SQL-based, using PHP code instead of SQL statements (which would mean that your issue is not xnttdb-related).Again, I don't really understand what you want to do but maybe, you just need to use entity reference fields? If you don't want to create an xnttdb that has the JOINs in your SQL query, then you could create 2 (or more) external entity types that use xnttdb queries: one for your main table and one for the "joined" table separately. You would have an xntt "A" and an xntt "B". Then, you would add an entity reference field on your xntt "A" that references one or more xntt "B" and you would get the identifiers from the xntt "A" SQL query. You can give me an example of 2 SQL tables and I could develop my example on those. Are you using PostgreSQL by the way?
Another possible approach is to use xnttmulti β module. You would have 2 xnttdb sources and the second one would use a join on the given field from the first one. But it means the xntt would always have the joined table and it would be a 1-to-1 relationship which may not be the behavior you're looking for.
- Status changed to Postponed: needs info
about 1 year ago 8:24am 9 November 2023 - π΅π±Poland adpo
Hi! Thank you so much for mentioning xnttviewsβit will certainly help maintain the external entity.
Regarding the initial question, let me try to explain with an example. Each user entity has a school_id field, and in the external database (also connected), there is a column that contains school_id as well as a representative column (rep_name). To filter users by rep_name, I would need to create a third join. However, I assume, as you mentioned, there is no way to use an xnttdb SQL query to add joins.
Thanks for the prompt response and the detailed answer.
- Status changed to Closed: won't fix
11 months ago 9:10am 23 February 2024