Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ jobs:
uses: moonrepo/setup-rust@v1
with:
components: rustfmt
bins: taplo-cli
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The release binary, because building taplo-cli without its lockfile picks up
# dependencies that need a newer Rust than our toolchain.
- name: Install taplo
run: |
curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz \
| gunzip > "$HOME/.cargo/bin/taplo"
chmod +x "$HOME/.cargo/bin/taplo"
taplo --version

- name: Setup Bun
uses: oven-sh/setup-bun@v2
Expand Down Expand Up @@ -329,10 +336,17 @@ jobs:
uses: moonrepo/setup-rust@v1
with:
components: rustfmt
bins: taplo-cli
cache-base: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The release binary, because building taplo-cli without its lockfile picks up
# dependencies that need a newer Rust than our toolchain.
- name: Install taplo
run: |
curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz \
| gunzip > "$HOME/.cargo/bin/taplo"
chmod +x "$HOME/.cargo/bin/taplo"
taplo --version
- uses: actions/cache@v5
with:
path: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,21 @@ impl LinterRule for AvoidAddingExclusionConstraint {
for cmd in &stmt.cmds {
if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node
&& cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddConstraint
{
if let Some(pgls_query::NodeEnum::Constraint(constraint)) =
&& let Some(pgls_query::NodeEnum::Constraint(constraint)) =
cmd.def.as_ref().and_then(|d| d.node.as_ref())
{
if constraint.contype()
== pgls_query::protobuf::ConstrType::ConstrExclusion
{
diagnostics.push(exclusion_diagnostic());
}
}
&& constraint.contype() == pgls_query::protobuf::ConstrType::ConstrExclusion
{
diagnostics.push(exclusion_diagnostic());
}
}
}
pgls_query::NodeEnum::CreateStmt(stmt) => {
for constraint_node in &stmt.constraints {
if let Some(pgls_query::NodeEnum::Constraint(constraint)) =
&constraint_node.node
&& constraint.contype() == pgls_query::protobuf::ConstrType::ConstrExclusion
{
if constraint.contype() == pgls_query::protobuf::ConstrType::ConstrExclusion
{
diagnostics.push(exclusion_diagnostic());
}
diagnostics.push(exclusion_diagnostic());
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/pgls_analyser/src/lint/safety/ban_vacuum_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ impl LinterRule for BanVacuumFull {
fn run(ctx: &LinterRuleContext<Self>) -> Vec<LinterDiagnostic> {
let mut diagnostics = vec![];

if let pgls_query::NodeEnum::VacuumStmt(stmt) = &ctx.stmt() {
if is_vacuum_full(stmt) {
diagnostics.push(
if let pgls_query::NodeEnum::VacuumStmt(stmt) = &ctx.stmt()
&& is_vacuum_full(stmt)
{
diagnostics.push(
LinterDiagnostic::new(
rule_category!(),
None,
Expand All @@ -54,7 +55,6 @@ impl LinterRule for BanVacuumFull {
"Use regular VACUUM or pg_repack for online table maintenance without blocking reads and writes.",
),
);
}
}

diagnostics
Expand Down
5 changes: 2 additions & 3 deletions crates/pgls_analyser/src/lint/safety/changing_column_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ impl LinterRule for ChangingColumnType {
{
if let Some(pgls_query::NodeEnum::ColumnDef(col_def)) =
cmd.def.as_ref().and_then(|d| d.node.as_ref())
&& is_safe_type_widening(col_def)
{
if is_safe_type_widening(col_def) {
continue;
}
continue;
}

diagnostics.push(LinterDiagnostic::new(
Expand Down
6 changes: 2 additions & 4 deletions crates/pgls_analyser/src/lint/safety/prefer_robust_stmts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ impl LinterRule for PreferRobustStmts {
);
}
}
pgls_query::NodeEnum::CreateStmt(stmt) => {
if !stmt.if_not_exists {
diagnostics.push(
pgls_query::NodeEnum::CreateStmt(stmt) if !stmt.if_not_exists => {
diagnostics.push(
LinterDiagnostic::new(
rule_category!(),
None,
Expand All @@ -146,7 +145,6 @@ impl LinterRule for PreferRobustStmts {
"Add IF NOT EXISTS to make the migration re-runnable if it fails.",
),
);
}
}
_ => {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ impl LinterRule for RequireConcurrentReindex {
fn run(ctx: &LinterRuleContext<Self>) -> Vec<LinterDiagnostic> {
let mut diagnostics = vec![];

if let pgls_query::NodeEnum::ReindexStmt(stmt) = &ctx.stmt() {
if !is_reindex_concurrent(stmt) {
diagnostics.push(
if let pgls_query::NodeEnum::ReindexStmt(stmt) = &ctx.stmt()
&& !is_reindex_concurrent(stmt)
{
diagnostics.push(
LinterDiagnostic::new(
rule_category!(),
None,
Expand All @@ -55,7 +56,6 @@ impl LinterRule for RequireConcurrentReindex {
"Use REINDEX CONCURRENTLY to rebuild the index without blocking reads and writes.",
),
);
}
}

diagnostics
Expand Down
28 changes: 13 additions & 15 deletions crates/pgls_analyser/src/linter_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ impl TransactionState {
self.transaction_depth += 1;
}
TransactionStmtKind::TransStmtRelease
| TransactionStmtKind::TransStmtRollbackTo => {
if self.transaction_depth > 0 {
self.transaction_depth -= 1;
}
| TransactionStmtKind::TransStmtRollbackTo
if self.transaction_depth > 0 =>
{
self.transaction_depth -= 1;
}
_ => {}
}
Expand Down Expand Up @@ -456,18 +456,16 @@ impl TransactionState {
for cmd in &alter_stmt.cmds {
if let Some(pgls_query::NodeEnum::AlterTableCmd(cmd)) = &cmd.node
&& cmd.subtype() == pgls_query::protobuf::AlterTableType::AtAddConstraint
{
if let Some(pgls_query::NodeEnum::Constraint(constraint)) =
&& let Some(pgls_query::NodeEnum::Constraint(constraint)) =
cmd.def.as_ref().and_then(|d| d.node.as_ref())
{
if constraint.skip_validation && !constraint.conname.is_empty() {
self.not_valid_constraints.push((
table_schema.clone(),
table_name.clone(),
constraint.conname.clone(),
));
}
}
&& constraint.skip_validation
&& !constraint.conname.is_empty()
{
self.not_valid_constraints.push((
table_schema.clone(),
table_name.clone(),
constraint.conname.clone(),
));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/pgls_cli/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl CliAdvice {
impl Advices for CliAdvice {
fn record(&self, visitor: &mut dyn Visit) -> std::io::Result<()> {
let command_name = command_name();
let help_sub_command = format!("{} {} --help", command_name, &self.sub_command);
let help_sub_command = format!("{} {} --help", command_name, self.sub_command);
visitor.record_log(
LogCategory::Info,
&markup! { "Type the following command for more information" },
Expand Down
2 changes: 1 addition & 1 deletion crates/pgls_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static GLOBAL: std::alloc::System = std::alloc::System;

fn main() -> ExitCode {
setup_panic_handler();
set_bottom_frame(main as usize);
set_bottom_frame(main as *const () as usize);

let mut console = EnvConsole::default();
let command = pg_l_s_command().fallback_to_usage().run();
Expand Down
14 changes: 7 additions & 7 deletions crates/pgls_completions/src/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ impl CompletionAssertion {
assert_eq!(
&item.label, label,
"Expected label to be {}, but got {}",
label, &item.label
label, item.label
);
}
CompletionAssertion::LabelAndKind(label, kind) => {
assert_eq!(
&item.label, label,
"Expected label to be {}, but got {}",
label, &item.label
label, item.label
);
assert_eq!(
&item.kind, kind,
"Expected kind to be {:?}, but got {:?}",
kind, &item.kind
kind, item.kind
);
}
CompletionAssertion::LabelNotExists(label) => {
Expand All @@ -125,12 +125,12 @@ impl CompletionAssertion {
assert_eq!(
&item.label, label,
"Expected label to be {}, but got {}",
label, &item.label
label, item.label
);
assert_eq!(
&item.description, desc,
"Expected desc to be {}, but got {}",
desc, &item.description
desc, item.description
);
}
CompletionAssertion::CompletionTextAndRange(txt, text_range) => {
Expand All @@ -152,7 +152,7 @@ impl CompletionAssertion {
text_range,
item.completion_text
.as_ref()
.map(|t| format!("{:?}", &t.range))
.map(|t| format!("{:?}", t.range))
.unwrap_or("None".to_string())
);
}
Expand Down Expand Up @@ -195,7 +195,7 @@ pub(crate) async fn assert_complete_results(

existing
.into_iter()
.zip(items.into_iter())
.zip(items)
.for_each(|(assertion, result)| {
assertion.assert(&result);
});
Expand Down
Loading
Loading