Skip to content

Commit

Permalink
Deal with some MariaDB strict options.
Browse files Browse the repository at this point in the history
Empty IN, bool ints, strict group by.
  • Loading branch information
dracos committed Dec 18, 2023
1 parent 72b0d16 commit fd6b634
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions classes/Divisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public function getRecentDebatesWithDivisions($number = 20, $majors = null) {
# Fetch any division speech, its subsection gid for the link, and
# section/subsection bodies to construct a debate title
$q = $this->db->query(
"SELECT eps.body as section_body, epss.body as subsection_body,
ss.gid as debate_gid, h.gid, h.hdate, h.major, count(h.gid) AS c
"SELECT min(eps.body) as section_body, min(epss.body) as subsection_body,
min(ss.gid) as debate_gid, min(h.gid), min(h.hdate), min(h.major), count(h.gid) AS c
FROM hansard h, hansard ss, epobject eps, epobject epss
WHERE h.section_id = eps.epobject_id
AND h.subsection_id = epss.epobject_id
Expand Down
17 changes: 14 additions & 3 deletions classes/PartyCohort.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,25 @@ public static function getCohortQuery(){
from
(select
person_id,
REPLACE(COALESCE(party), "/Co-operative", "") as "start_party",
GROUP_CONCAT(concat(entered_house,":", left_house)) as "membership_key"
REPLACE(COALESCE(m2party), "/Co-operative", "") as "start_party",
GROUP_CONCAT(concat(entered_house,":", left_house) ORDER BY entered_house) as "membership_key"
from
member
inner join
(
select party m2party, person_id m2pid
from member
where
house = :house and entered_house > :cut_off
and entered_house = (select min(entered_house) from member m3 where house=:house and entered_house > :cut_off and member.person_id=m3.person_id)
) m2
ON member.person_id = m2.m2pid
where
house = :house and entered_house > :cut_off
group by person_id
order by person_id, entered_house
order by person_id
)as member_periods
left join
(select
Expand Down
7 changes: 7 additions & 0 deletions classes/Utility/Wikipedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public static function wikipedize($source) {
$params[':phrase' . $i] = $phrase;
}

if (!$params) {
if ($was_array) {
$source = explode('|||', $source);
}
return $source;
}

# Open up a db connection, and whittle our list down even further, against
# the real titles.
$matched = array();
Expand Down
4 changes: 2 additions & 2 deletions tests/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testEditUser() {
'postcode' => 'EH1 99SP',
'password' => '',
'url' => '',
'optin' => '',
'optin' => 0,
'user_id' => 1
) );

Expand All @@ -81,7 +81,7 @@ public function testEditUserEmail() {
'postcode' => 'EH1 99SP',
'password' => '',
'url' => '',
'optin' => '',
'optin' => 0,
'user_id' => 1
), false );

Expand Down

0 comments on commit fd6b634

Please sign in to comment.