mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
Ruby: add databaseMetadata relation to dbscheme
This is required for overlay support.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
"/*- Diagnostic messages -*/",
|
||||
"/*- Diagnostic messages: severity -*/",
|
||||
"/*- Source location prefix -*/",
|
||||
"/*- Database metadata -*/",
|
||||
"/*- Lines of code -*/",
|
||||
"/*- Configuration files with key value pairs -*/",
|
||||
"/*- YAML -*/",
|
||||
@@ -31,4 +32,4 @@
|
||||
"/*- Python dbscheme -*/",
|
||||
"/*- Empty location -*/"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,5 +36,5 @@ pub fn run(options: Options) -> std::io::Result<()> {
|
||||
},
|
||||
];
|
||||
|
||||
generate(languages, options.dbscheme, options.library)
|
||||
generate(languages, options.dbscheme, options.library, false)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
description: Add databaseMetadata relation
|
||||
compatibility: full
|
||||
databaseMetadata.rel: delete
|
||||
@@ -28,5 +28,5 @@ pub fn run(options: Options) -> std::io::Result<()> {
|
||||
},
|
||||
];
|
||||
|
||||
generate(languages, options.dbscheme, options.library)
|
||||
generate(languages, options.dbscheme, options.library, true)
|
||||
}
|
||||
|
||||
@@ -108,6 +108,12 @@ yaml_locations(unique int locatable: @yaml_locatable ref,
|
||||
|
||||
@yaml_locatable = @yaml_node | @yaml_error;
|
||||
|
||||
/*- Database metadata -*/
|
||||
databaseMetadata(
|
||||
string metadataKey: string ref,
|
||||
string value: string ref
|
||||
);
|
||||
|
||||
/*- Ruby dbscheme -*/
|
||||
@ruby_underscore_arg = @ruby_assignment | @ruby_binary | @ruby_conditional | @ruby_operator_assignment | @ruby_range | @ruby_unary | @ruby_underscore_primary
|
||||
|
||||
|
||||
@@ -21521,6 +21521,42 @@
|
||||
</dep>
|
||||
</dependencies>
|
||||
</relation>
|
||||
<relation>
|
||||
<name>databaseMetadata</name>
|
||||
<cardinality>1</cardinality>
|
||||
<columnsizes>
|
||||
<e>
|
||||
<k>metadataKey</k>
|
||||
<v>1</v>
|
||||
</e>
|
||||
<e>
|
||||
<k>value</k>
|
||||
<v>1</v>
|
||||
</e>
|
||||
</columnsizes>
|
||||
<dependencies>
|
||||
<dep>
|
||||
<src>metadataKey</src>
|
||||
<trg>value</trg>
|
||||
<val>
|
||||
<hist>
|
||||
<budget>12</budget>
|
||||
<bs/>
|
||||
</hist>
|
||||
</val>
|
||||
</dep>
|
||||
<dep>
|
||||
<src>value</src>
|
||||
<trg>metadataKey</trg>
|
||||
<val>
|
||||
<hist>
|
||||
<budget>12</budget>
|
||||
<bs/>
|
||||
</hist>
|
||||
</val>
|
||||
</dep>
|
||||
</dependencies>
|
||||
</relation>
|
||||
<relation>
|
||||
<name>yaml_aliases</name>
|
||||
<cardinality>0</cardinality>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Add databaseMetadata relation
|
||||
compatibility: full
|
||||
@@ -17,6 +17,7 @@ pub fn generate(
|
||||
languages: Vec<language::Language>,
|
||||
dbscheme_path: PathBuf,
|
||||
ql_library_path: PathBuf,
|
||||
add_metadata_relation: bool,
|
||||
) -> std::io::Result<()> {
|
||||
let dbscheme_file = File::create(dbscheme_path).map_err(|e| {
|
||||
tracing::error!("Failed to create dbscheme file: {}", e);
|
||||
@@ -32,6 +33,16 @@ pub fn generate(
|
||||
|
||||
writeln!(dbscheme_writer, include_str!("prefix.dbscheme"))?;
|
||||
|
||||
// Eventually all languages will have the metadata relation (for overlay support), at which
|
||||
// point this could be moved to prefix.dbscheme.
|
||||
if add_metadata_relation {
|
||||
writeln!(dbscheme_writer, "/*- Database metadata -*/",)?;
|
||||
dbscheme::write(
|
||||
&mut dbscheme_writer,
|
||||
&[dbscheme::Entry::Table(create_database_metadata())],
|
||||
)?;
|
||||
}
|
||||
|
||||
let mut ql_writer = LineWriter::new(File::create(ql_library_path)?);
|
||||
writeln!(
|
||||
ql_writer,
|
||||
@@ -442,3 +453,26 @@ fn create_token_case<'a>(name: &'a str, token_kinds: Map<&'a str, usize>) -> dbs
|
||||
branches,
|
||||
}
|
||||
}
|
||||
|
||||
fn create_database_metadata() -> dbscheme::Table<'static> {
|
||||
dbscheme::Table {
|
||||
name: "databaseMetadata",
|
||||
keysets: None,
|
||||
columns: vec![
|
||||
dbscheme::Column {
|
||||
db_type: dbscheme::DbColumnType::String,
|
||||
name: "metadataKey",
|
||||
unique: false,
|
||||
ql_type: ql::Type::String,
|
||||
ql_type_is_ref: true,
|
||||
},
|
||||
dbscheme::Column {
|
||||
db_type: dbscheme::DbColumnType::String,
|
||||
name: "value",
|
||||
unique: false,
|
||||
ql_type: ql::Type::String,
|
||||
ql_type_is_ref: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user