Skip to content

Commit 035000c

Browse files
authored
Merge pull request #289 from erizocosmico/feature/commit_blobs-squash
*: remove commit_has_blob, squash rule for commit_blobs
2 parents 9ecb8a5 + eb93f0f commit 035000c

8 files changed

+497
-1007
lines changed

integration_test.go

+33-9
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ func TestIntegration(t *testing.T) {
3939
{
4040
`SELECT COUNT(c.commit_hash), c.commit_hash
4141
FROM ref_commits r
42-
INNER JOIN commits c
42+
INNER JOIN commit_blobs c
4343
ON r.ref_name = 'HEAD' AND r.commit_hash = c.commit_hash
4444
INNER JOIN blobs b
45-
ON commit_has_blob(c.commit_hash, b.blob_hash)
45+
ON c.blob_hash = b.blob_hash
4646
GROUP BY c.commit_hash`,
4747
[]sql.Row{
4848
{int32(4), "1669dce138d9b841a518c64b10914d88f5e488ea"},
@@ -223,10 +223,19 @@ func TestSquashCorrectness(t *testing.T) {
223223
`SELECT * FROM refs r INNER JOIN commits c ON r.commit_hash = c.commit_hash`,
224224
`SELECT * FROM ref_commits r INNER JOIN commits c ON r.commit_hash = c.commit_hash`,
225225
`SELECT * FROM refs r INNER JOIN commit_trees t ON r.commit_hash = t.commit_hash`,
226-
`SELECT * FROM refs r INNER JOIN blobs b ON commit_has_blob(r.commit_hash, b.blob_hash)`,
226+
`SELECT * FROM refs r INNER JOIN commit_blobs b ON r.commit_hash = b.commit_hash`,
227+
`SELECT * FROM refs r
228+
INNER JOIN commit_blobs cb
229+
ON r.commit_hash = cb.commit_hash
230+
INNER JOIN blobs b
231+
ON cb.blob_hash = b.blob_hash`,
227232
`SELECT * FROM commits c INNER JOIN commit_trees t ON c.commit_hash = t.tree_hash`,
228233
`SELECT * FROM commits c INNER JOIN tree_entries te ON c.tree_hash = te.tree_hash`,
229-
`SELECT * FROM commits c INNER JOIN blobs b ON commit_has_blob(c.commit_hash, b.blob_hash)`,
234+
`SELECT * FROM commits c
235+
INNER JOIN commit_blobs cb
236+
ON c.commit_hash = cb.commit_hash
237+
INNER JOIN blobs b
238+
ON cb.blob_hash = b.blob_hash`,
230239
`SELECT * FROM tree_entries te INNER JOIN blobs b ON te.blob_hash = b.blob_hash`,
231240

232241
`SELECT * FROM repositories r
@@ -248,6 +257,17 @@ func TestSquashCorrectness(t *testing.T) {
248257
`SELECT * FROM repositories,
249258
commits c INNER JOIN tree_entries te
250259
ON c.tree_hash = te.tree_hash`,
260+
261+
`SELECT * FROM refs r
262+
INNER JOIN ref_commits c
263+
ON r.ref_name = c.ref_name
264+
AND c.repository_id = r.repository_id`,
265+
266+
`SELECT * FROM refs r
267+
INNER JOIN ref_commits c
268+
ON r.commit_hash = c.commit_hash
269+
AND r.ref_name = c.ref_name
270+
AND c.repository_id = r.repository_id`,
251271
}
252272

253273
for _, q := range queries {
@@ -319,13 +339,13 @@ func BenchmarkQueries(b *testing.B) {
319339
ON r.repository_id = rr.repository_id`,
320340
},
321341
{
322-
"query with commit_has_blob",
342+
"query with commit_blobs",
323343
`SELECT COUNT(c.commit_hash), c.commit_hash
324344
FROM ref_commits r
325-
INNER JOIN commits c
345+
INNER JOIN commit_blobs c
326346
ON r.ref_name = 'HEAD' AND r.commit_hash = c.commit_hash
327347
INNER JOIN blobs b
328-
ON commit_has_blob(c.commit_hash, b.blob_hash)
348+
ON c.blob_hash = b.blob_hash
329349
GROUP BY c.commit_hash`,
330350
},
331351
{
@@ -367,14 +387,18 @@ func BenchmarkQueries(b *testing.B) {
367387
{
368388
"join refs and blobs",
369389
`SELECT * FROM refs r
390+
INNER JOIN commit_blobs cb
391+
ON r.commit_hash = cb.commit_hash
370392
INNER JOIN blobs b
371-
ON commit_has_blob(r.commit_hash, b.blob_hash)`,
393+
ON cb.blob_hash = b.blob_hash`,
372394
},
373395
{
374396
"join refs and blobs with filters",
375397
`SELECT * FROM refs r
398+
INNER JOIN commit_blobs cb
399+
ON r.commit_hash = cb.commit_hash
376400
INNER JOIN blobs b
377-
ON commit_has_blob(r.commit_hash, b.blob_hash)
401+
ON cb.blob_hash = b.blob_hash
378402
WHERE r.ref_name = 'refs/heads/master'`,
379403
},
380404
}

internal/function/commit_has_blob.go

-236
This file was deleted.

0 commit comments

Comments
 (0)