Skip to content

Commit e78cf04

Browse files
committed
Standardize license headers
Standardize the license header, removing the Grove Enterprise copyright notice where it exists per apache#58. Also add a CI check to ensure that files without license headers don't get merged. Fix apache#58.
1 parent 1f87083 commit e78cf04

24 files changed

+282
-11
lines changed

Diff for: .travis.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ before_script:
3636
- cargo install cargo-update || echo "cargo-update already installed"
3737
- cargo install cargo-travis || echo "cargo-travis already installed"
3838
- cargo install-update -a # updates cargo-travis, if the cached version is outdated
39-
- rustup component add clippy rustfmt
39+
- rustup component add clippy
40+
# The license_template_path setting we use to verify copyright headers is
41+
# only available on the nightly rustfmt.
42+
- rustup toolchain install nightly && rustup component add --toolchain nightly rustfmt
4043

4144
script:
4245
# Clippy must be run first, as its lints are only triggered during
@@ -46,7 +49,7 @@ script:
4649
- travis-cargo clippy -- --all-targets --all-features -- -D warnings
4750
- travis-cargo build
4851
- travis-cargo test
49-
- travis-cargo fmt -- -- --check
52+
- travis-cargo --only nightly fmt -- -- --check --config-path <(echo 'license_template_path = "HEADER"')
5053

5154
after_success:
5255
- cargo coveralls --verbose

Diff for: HEADER

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.

Diff for: examples/cli.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
#![warn(clippy::all)]
214

315
use simple_logger;

Diff for: examples/parse_select.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
#![warn(clippy::all)]
214

315
use sqlparser::dialect::GenericSqlDialect;

Diff for: rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# We use rustfmt's default settings to format the source code
1+
# We use rustfmt's default settings to format the source code

Diff for: src/dialect/ansi_sql.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use crate::dialect::Dialect;
214

315
#[derive(Debug)]

Diff for: src/dialect/generic_sql.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use crate::dialect::Dialect;
214

315
#[derive(Debug)]

Diff for: src/dialect/keywords.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
///! This module defines
214
/// 1) a list of constants for every keyword that
315
/// can appear in SQLWord::keyword:

Diff for: src/dialect/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
mod ansi_sql;
214
mod generic_sql;
315
pub mod keywords;

Diff for: src/dialect/mssql.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use crate::dialect::Dialect;
214

315
#[derive(Debug)]

Diff for: src/dialect/postgresql.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use crate::dialect::Dialect;
214

315
#[derive(Debug)]

Diff for: src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Copyright 2018 Grove Enterprises LLC
2-
//
31
// Licensed under the Apache License, Version 2.0 (the "License");
42
// you may not use this file except in compliance with the License.
53
// You may obtain a copy of the License at

Diff for: src/sqlast/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Copyright 2018 Grove Enterprises LLC
2-
//
31
// Licensed under the Apache License, Version 2.0 (the "License");
42
// you may not use this file except in compliance with the License.
53
// You may obtain a copy of the License at

Diff for: src/sqlast/query.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use super::*;
214

315
/// The most complete variant of a `SELECT` query expression, optionally

Diff for: src/sqlast/sql_operator.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
/// SQL Operator
214
#[derive(Debug, Clone, PartialEq, Hash)]
315
pub enum SQLOperator {

Diff for: src/sqlast/sqltype.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use super::SQLObjectName;
214

315
/// SQL data types

Diff for: src/sqlast/table_key.rs

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
13+
use super::{SQLIdent, SQLObjectName};
14+
15+
#[derive(Debug, Clone, PartialEq)]
16+
pub enum AlterOperation {
17+
AddConstraint(TableKey),
18+
RemoveConstraint { name: SQLIdent },
19+
}
20+
21+
impl ToString for AlterOperation {
22+
fn to_string(&self) -> String {
23+
match self {
24+
AlterOperation::AddConstraint(table_key) => {
25+
format!("ADD CONSTRAINT {}", table_key.to_string())
26+
}
27+
AlterOperation::RemoveConstraint { name } => format!("REMOVE CONSTRAINT {}", name),
28+
}
29+
}
30+
}
31+
32+
#[derive(Debug, Clone, PartialEq)]
33+
pub struct Key {
34+
pub name: SQLIdent,
35+
pub columns: Vec<SQLIdent>,
36+
}
37+
38+
#[derive(Debug, Clone, PartialEq)]
39+
pub enum TableKey {
40+
PrimaryKey(Key),
41+
UniqueKey(Key),
42+
Key(Key),
43+
ForeignKey {
44+
key: Key,
45+
foreign_table: SQLObjectName,
46+
referred_columns: Vec<SQLIdent>,
47+
},
48+
}
49+
50+
impl ToString for TableKey {
51+
fn to_string(&self) -> String {
52+
match self {
53+
TableKey::PrimaryKey(ref key) => {
54+
format!("{} PRIMARY KEY ({})", key.name, key.columns.join(", "))
55+
}
56+
TableKey::UniqueKey(ref key) => {
57+
format!("{} UNIQUE KEY ({})", key.name, key.columns.join(", "))
58+
}
59+
TableKey::Key(ref key) => format!("{} KEY ({})", key.name, key.columns.join(", ")),
60+
TableKey::ForeignKey {
61+
key,
62+
foreign_table,
63+
referred_columns,
64+
} => format!(
65+
"{} FOREIGN KEY ({}) REFERENCES {}({})",
66+
key.name,
67+
key.columns.join(", "),
68+
foreign_table.to_string(),
69+
referred_columns.join(", ")
70+
),
71+
}
72+
}
73+
}

Diff for: src/sqlast/value.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use ordered_float::OrderedFloat;
214

315
/// Primitive SQL values such as number and string

Diff for: src/sqlparser.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Copyright 2018 Grove Enterprises LLC
2-
//
31
// Licensed under the Apache License, Version 2.0 (the "License");
42
// you may not use this file except in compliance with the License.
53
// You may obtain a copy of the License at

Diff for: src/sqltokenizer.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Copyright 2018 Grove Enterprises LLC
2-
//
31
// Licensed under the Apache License, Version 2.0 (the "License");
42
// you may not use this file except in compliance with the License.
53
// You may obtain a copy of the License at

Diff for: src/test_utils.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
use std::fmt::Debug;
214

315
use super::dialect::*;

Diff for: tests/sqlparser_common.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
#![warn(clippy::all)]
214
//! Test SQL syntax, which all sqlparser dialects must parse in the same way.
315
//!

Diff for: tests/sqlparser_mssql.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
#![warn(clippy::all)]
214
//! Test SQL syntax specific to Microsoft's T-SQL. The parser based on the
315
//! generic dialect is also tested (on the inputs it can handle).

Diff for: tests/sqlparser_postgres.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
113
#![warn(clippy::all)]
214
//! Test SQL syntax specific to PostgreSQL. The parser based on the
315
//! generic dialect is also tested (on the inputs it can handle).

0 commit comments

Comments
 (0)