this repo has no description

.

+35
+2
db.py
··· 94 94 def INNER_JOIN(self, a, b, pred): 95 95 return self.CROSS_JOIN(a, b).filter(pred) 96 96 97 + JOIN = INNER_JOIN 98 + 97 99 def LEFT_JOIN(self, a, b, pred): 98 100 rows = [] 99 101 empty_b_row = {f"{b.name}.{k}": None for k in b.colnames()}
+33
db_tests.py
··· 170 170 ), 171 171 ) 172 172 173 + def test_inner_join_returns_matching_cross_product(self): 174 + user = Table("user", [{"id": 1, "name": "Alice"}]) 175 + post = Table( 176 + "post", 177 + [ 178 + {"id": 1, "user_id": 1, "title": "Hello"}, 179 + {"id": 2, "user_id": 2, "title": "Hello world"}, 180 + {"id": 3, "user_id": 1, "title": "Goodbye world"}, 181 + {"id": 2, "user_id": 3, "title": "Hello world again"}, 182 + ], 183 + ) 184 + db = Database() 185 + result = db.JOIN(user, post, lambda row: row["user.id"] == row["post.user_id"]) 186 + self.assertEqual( 187 + result.rows, 188 + ( 189 + { 190 + "post.id": 1, 191 + "post.title": "Hello", 192 + "post.user_id": 1, 193 + "user.id": 1, 194 + "user.name": "Alice", 195 + }, 196 + { 197 + "post.id": 3, 198 + "post.title": "Goodbye world", 199 + "post.user_id": 1, 200 + "user.id": 1, 201 + "user.name": "Alice", 202 + }, 203 + ), 204 + ) 205 + 173 206 174 207 if __name__ == "__main__": 175 208 unittest.main()