Closed bell1jl closed 3 years ago
Hi @bell1jl
For a where
clause you need to add .meta_value
to custom (metadata) fields.
Cheers, Jory
How do I get the ID of those fields? .meta_value.ID?
On Thu, Feb 11, 2021 at 4:16 AM Jory Hogeveen notifications@github.com wrote:
Hi @bell1jl https://github.com/bell1jl
For a where clause you need to add .meta_value to custom (metadata) fields.
Cheers, Jory
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pods-framework/pods/issues/5935#issuecomment-777301443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGAO5KY6NTHQP73FZVVIETS6OOAPANCNFSM4XNSMHTQ .
@JoryHogeveen I'm not trying to get the value, I'm trying to get the ID. I understand that if I wanted the value, I'd need to use the .meta_value reference. But I'm trying to get the ID of object. In every other example I've seen, I've just used field.ID
and it worked perfectly fine. In fact, in the example above, I can use each statement with field.ID
and I get the correct items returned. It's only when I combine the two statements that I get no results.
Here are the exact shortcodes and output I'm seeing. No matter if I start with the training_video
object or the user
object, the result is the same when I try to combine a query using associated IDs from each.
WORKS
[pods name="training_video" where="ID=612"]
<table>
[each completed_by_users]
<tr><td>{@display_name}</td><td>{@ID}</td></tr>
[/each]
</table>
[/pods]
WORKS
[pods name="training_video" where="completed_by_users.ID=4"]
<table>
[each completed_by_users]
<tr><td>{@display_name}</td><td>{@ID}</td></tr>
[/each]
</table>
[/pods]
OUTPUT
DOES NOT WORK
[pods name="training_video" where="completed_by_users.ID=4 AND ID=612"]
<table>
[each completed_by_users]
<tr><td>{@display_name}</td><td>{@ID}</td></tr>
[/each]
</table>
[/pods]
OUTPUT
@JoryHogeveen he's not using a meta value, he's using an ID to match against. This is going to require pulling in his export, I believe.
Issue Overview
I have an extended users object with a relationship field named "videos_completed". I can have the shortcode output {@videos_completed.ID} on the user object with one item in my WHERE clause. I can query WHERE user.ID=4 and have that return data. I can also query WHERE videos_completed.ID=612 and have it return data. But when I combine the two clauses into WHERE user.ID=4 AND videos_completed.ID=612 I get nothing.
Expected Behavior
Not much to say here. I'm expecting the WHERE clause to allow an AND on a related field ID.
Current Behavior
Steps to Reproduce (for bugs)
[pods name="user" where="ID="]
User.ID Only: {@videos_completed.ID}
[/pods]
[pods name="user" where="videos_completed.ID="]
Video ID Only: {@videos_completed.ID}
[/pods]
[pods name="user" where="ID= AND videos_completed.ID="]
Both: {@videos_completed.ID}
[/pods]
You should return the @videos_complete.ID for for the User.ID Only, the Video ID Only, but not both.
Possible Solution
WordPress Environment
Pods Package Export (helpful!)
Workaround or Alternate Solution Until Bug is Addressed
Related Issues and/or PRs