API page: https://api.drupal.org/api/drupal/includes%21database%21database.inc/gro...

"one might wish to return a list of the most recent 10 nodes authored by a given user"

The query presented doesn't do "ORDER BY n.created DESC" so it will present 10 entries, but they may not be recent.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Title: database documentation - order by required » Fix example query in Database topic to include ORDER BY
Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7, +Novice

Thanks for filing this issue -- good catch!

This needs to be fixed in 8.x first (same docs there).

KelvinWong’s picture

Status: Active » Needs review
FileSize
952 bytes

I have updated the documentation. Please review :)

sphism’s picture

I'll do this now (in DrupalSouth code sprint) .... edit, it's just been done, so i'll review it :)

sphism’s picture

Why does that patch say deleted?

sphism’s picture

+++ b/core/includes/database.inc
@@ -39,12 +39,14 @@
+ *   ORDER BY e.created DESC LIMIT 0, 10;

If ORDER BY is on a separate line, should FROM and WHERE each be on separate lines as well? I'm not sure of the convention for this

KelvinWong’s picture

FileSize
952 bytes

I break it to a new line because it excess the 80 characters limit on a line. Just found a mistake on the patch, attached a new one.

sphism’s picture

I didn't think the 80 char limit applied to code blocks.... hmmm i could be wrong.

i'm not sure where you would break the line, it's usually word wrapped at the last word that goes over 80 chars regardless of what looks right.

I assume we are in the same code sprint, where are you?

sphism’s picture

Some things in your @code blocks are indented, should they be? I'm not sure and the comment guidelines don't help with multi line code comments:

https://drupal.org/node/1354#code

KelvinWong’s picture

I am sitting at the table near the entry, there are 3 people only at my table.

May be it shouldn't be indented in the @code blocks, I will check it out. Thanks.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

It is fine to indent in code blocks, and while they can go over 80 lines, really long lines do not display well on api.drupal.org. The main thing is to keep them readable. :)

So I think this patch is fine. Thanks!

danblack’s picture

Thanks for the patch folks. Works for me. I really enjoyed Drupal South. So much so I forgot to check back on this bug.

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks again! Committed to 8.x.

I cannot get this to apply easily to 7.x, so this needs a port.

sphism’s picture

That's odd, I visited KelvinWong's user page and it doesn't mention he got a core commit, shouldn't it say something like:

Drupal core (1 commit)

???

droplet’s picture

@splhism,

CORE commit won't show on User Profiles. Yeah. It's odd design.

KelvinWong’s picture

Yay, my first contribution to Drupal core. Thanks for giving me the opportunity, and thanks everyone for your time to look at my patch and give comments. I will checkout the 7.x port.

Many Thanks.

jhodgdon’s picture

RE #13 - Nearly every Drupal Core commit involves multiple contributors (making patches, reviewing, etc.). Git only allows us to give one person credit for the patch. So, we use a different system in the Drupal Core patch, where we use the commit message to assign credit. If you go to the Drupal Core project and review the recent commits, you will find the drupal.org user names of (hopefully) everyone who contributed to a particular commit mentioned in the commit message. And when we recognize contributions to Drupal Core, we look at the content of those commit messages. Hope that explanation helps...

KelvinWong’s picture

FileSize
594 bytes

Please find attached patch for 7.x

sphism’s picture

Thanks jhodgdon, that explains it.

For people just starting out it's a huge encouragement to get that little bit of recognition on your profile page for what many have been a great many hours work.

jhodgdon’s picture

Status: Patch (to be ported) » Needs work

RE #18, sorry, but that's not under my control. For further discussion, please see:
#2042697: Add historical issue credits to Drupal.org user profile
and related issues.

Also see
https://drupal.org/node/52287

RE #17 - when you upload a patch, you need to set the status to "Needs Review". Thanks! However, in this case I don't think the patch is complete. It is missing lines that are in the 8.x patch.

KelvinWong’s picture

Status: Needs work » Needs review
FileSize
960 bytes

Sorry, forgot to update those in @code. New patch uploaded, please review.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks again! Committed to 7.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.