fix(protocol): accept uppercase completion candidate kinds
Closes #7511
This commit is contained in:
1 parent
e9f2cc15b7
commit
01ce303f46
1 file changed
+44
-1
@@ -233,14 +233,23 @@ impl CompletionAssistantObjectKind {
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CompletionAssistantCandidateKind {
|
||||
#[serde(alias = "DATABASE")]
|
||||
Database,
|
||||
#[serde(alias = "SCHEMA")]
|
||||
Schema,
|
||||
#[serde(alias = "TABLE")]
|
||||
Table,
|
||||
#[serde(alias = "VIEW")]
|
||||
View,
|
||||
#[serde(alias = "PROCEDURE")]
|
||||
Procedure,
|
||||
#[serde(alias = "FUNCTION")]
|
||||
Function,
|
||||
#[serde(alias = "COLUMN")]
|
||||
Column,
|
||||
#[serde(alias = "SEQUENCE")]
|
||||
Sequence,
|
||||
#[serde(alias = "OBJECT")]
|
||||
Object,
|
||||
}
|
||||
|
||||
@@ -692,7 +701,10 @@ pub struct CustomTypeDetails {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{ObjectInfo, ObjectSourceKind, QueryMessage, SpatialColumn, SpatialColumnBuilder};
|
||||
use super::{
|
||||
CompletionAssistantCandidate, CompletionAssistantCandidateKind, ObjectInfo, ObjectSourceKind, QueryMessage,
|
||||
SpatialColumn, SpatialColumnBuilder,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn query_message_format_line_uppercases_severity() {
|
||||
@@ -837,4 +849,35 @@ mod tests {
|
||||
assert_eq!(kind, ObjectSourceKind::Synonym);
|
||||
assert_eq!(serde_json::to_string(&kind).unwrap(), "\"SYNONYM\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completion_candidate_kind_accepts_uppercase_agent_wire_values() {
|
||||
for (wire_value, expected) in [
|
||||
("DATABASE", CompletionAssistantCandidateKind::Database),
|
||||
("SCHEMA", CompletionAssistantCandidateKind::Schema),
|
||||
("TABLE", CompletionAssistantCandidateKind::Table),
|
||||
("VIEW", CompletionAssistantCandidateKind::View),
|
||||
("PROCEDURE", CompletionAssistantCandidateKind::Procedure),
|
||||
("FUNCTION", CompletionAssistantCandidateKind::Function),
|
||||
("COLUMN", CompletionAssistantCandidateKind::Column),
|
||||
("SEQUENCE", CompletionAssistantCandidateKind::Sequence),
|
||||
("OBJECT", CompletionAssistantCandidateKind::Object),
|
||||
] {
|
||||
let payload = serde_json::json!({
|
||||
"name": "id",
|
||||
"kind": wire_value,
|
||||
"database": null,
|
||||
"schema": "public",
|
||||
"parent_schema": "public",
|
||||
"parent_name": "users",
|
||||
"comment": null,
|
||||
"data_type": "integer",
|
||||
"signature": null,
|
||||
});
|
||||
let candidate: CompletionAssistantCandidate = serde_json::from_value(payload).unwrap();
|
||||
|
||||
assert_eq!(candidate.kind, expected);
|
||||
assert_eq!(serde_json::to_value(candidate.kind).unwrap(), wire_value.to_ascii_lowercase());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user