Add upgrade script moving superclass exprs to own table

This commit is contained in:
Nick Rolfe
2021-01-29 15:11:56 +00:00
parent 443a992a90
commit d26822ad23
7 changed files with 3028 additions and 6 deletions

View File

@@ -1,6 +1,9 @@
{ "provide": [ "ql/src/qlpack.yml",
"ql/test/qlpack.yml",
"ql/examples/qlpack.yml",
"extractor-pack/codeql-extractor.yml"
]
}
{
"provide": [
"ql/src/qlpack.yml",
"ql/test/qlpack.yml",
"ql/examples/qlpack.yml",
"upgrades/qlpack.yml",
"extractor-pack/codeql-extractor.yml"
]
}

View File

@@ -0,0 +1,26 @@
class Superclass extends @superclass {
string toString() { result = "" }
}
class Class extends @class {
string toString() { result = "" }
}
class ClassChildType extends @class_child_type {
string toString() { result = "" }
}
// Select all non-superclass children.
// If the 0th child is a superclass, shuffle all the indexes down one. (Having
// superclass children at other indexes is allowed in the old dbscheme, but
// doesn't happen in practice, given the tree-sitter grammar).
from Class c, int oldIndex, ClassChildType child, int newIndex
where
class_child(c, oldIndex, child) and
(
if exists(Superclass sc | class_child(c, 0, sc))
then newIndex = oldIndex - 1
else newIndex = oldIndex
) and
not child instanceof Superclass
select c, newIndex, child

View File

@@ -0,0 +1,12 @@
class Superclass extends @superclass {
string toString() { result = "" }
}
class Class extends @class {
string toString() { result = "" }
}
// Select the 0th child if it's a @superclass
from Class c, Superclass sc
where class_child(c, 0, sc)
select c, sc

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
description: moves class superclass nodes into their own table
compatibility: full
class_superclass.rel: run class_superclass.qlo
class_child.rel: run class_child.qlo

2
upgrades/qlpack.yml Normal file
View File

@@ -0,0 +1,2 @@
name: codeql-ruby-upgrades
upgrades: .