Skip to content

Commit f784b76

Browse files
committed
Revert "fix: Patched SQL dialect issue LIMIT vs TOP in favor of Microsoft SQL Server (#101)"
This reverts commit 2fa7dc6. The solution to the SQL dialect issue is suboptimal. Moodle’s datalib provides the right means of abstraction to formulate our query without database-specific code. We can use the parameter $limitnum from the method get_records_sql of the class moodle_database.
1 parent c42df20 commit f784b76

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

classes/review.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,12 @@ public static function get_first_review_post($moodleoverflowid, $afterpostid = n
107107
$addwhere = ' AND p.id != :notpostid ';
108108
$params['notpostid'] = $afterpostid;
109109
}
110-
/* Handle different SQL dialects in favor of Microsoft SQL Server */
111-
if (is_a($DB, 'sqlsrv_native_moodle_database')) {
112-
$top = 'TOP 1';
113-
$limit = '';
114-
} else {
115-
$top = '';
116-
$limit = 'LIMIT 1';
117-
}
118110
$record = $DB->get_record_sql(
119-
"SELECT $top p.id as postid, p.discussion as discussionid FROM {moodleoverflow_posts} p " .
111+
'SELECT p.id as postid, p.discussion as discussionid FROM {moodleoverflow_posts} p ' .
120112
'JOIN {moodleoverflow_discussions} d ON d.id = p.discussion ' .
121113
"WHERE p.reviewed = 0 AND d.moodleoverflow = :moodleoverflowid AND p.created < :reviewtime $addwhere " .
122114
"ORDER BY $orderby p.discussion, p.id " .
123-
$limit,
115+
'LIMIT 1',
124116
$params
125117
);
126118
if ($record) {

0 commit comments

Comments
 (0)