Skip to content

Commit 9934f3d

Browse files
authored
Update to ASF header / add when missing (#1437)
1 parent fb42425 commit 9934f3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1006
-427
lines changed

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
# Changelog
221
All notable changes to this project will be documented in this file.
322

Cargo.toml

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
[package]
219
name = "sqlparser"
320
description = "Extensible SQL Lexer and Parser with support for ANSI SQL:2011"

HEADER

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
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
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
48
//
5-
// http://www.apache.org/licenses/LICENSE-2.0
9+
// http://www.apache.org/licenses/LICENSE-2.0
610
//
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.
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.

SECURITY.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
# Security Policy
221

322
## Reporting a Vulnerability

derive/Cargo.toml

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
[package]
219
name = "sqlparser_derive"
320
description = "proc macro for sqlparser"

derive/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
# SQL Parser Derive Macro
221

322
## Visit

derive/src/lib.rs

+57-22
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,53 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
118
use proc_macro2::TokenStream;
219
use quote::{format_ident, quote, quote_spanned, ToTokens};
320
use syn::spanned::Spanned;
421
use syn::{
522
parse::{Parse, ParseStream},
6-
parse_macro_input, parse_quote, Attribute, Data, DeriveInput,
7-
Fields, GenericParam, Generics, Ident, Index, LitStr, Meta, Token
23+
parse_macro_input, parse_quote, Attribute, Data, DeriveInput, Fields, GenericParam, Generics,
24+
Ident, Index, LitStr, Meta, Token,
825
};
926

10-
1127
/// Implementation of `[#derive(Visit)]`
1228
#[proc_macro_derive(VisitMut, attributes(visit))]
1329
pub fn derive_visit_mut(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
14-
derive_visit(input, &VisitType {
15-
visit_trait: quote!(VisitMut),
16-
visitor_trait: quote!(VisitorMut),
17-
modifier: Some(quote!(mut)),
18-
})
30+
derive_visit(
31+
input,
32+
&VisitType {
33+
visit_trait: quote!(VisitMut),
34+
visitor_trait: quote!(VisitorMut),
35+
modifier: Some(quote!(mut)),
36+
},
37+
)
1938
}
2039

2140
/// Implementation of `[#derive(Visit)]`
2241
#[proc_macro_derive(Visit, attributes(visit))]
2342
pub fn derive_visit_immutable(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
24-
derive_visit(input, &VisitType {
25-
visit_trait: quote!(Visit),
26-
visitor_trait: quote!(Visitor),
27-
modifier: None,
28-
})
43+
derive_visit(
44+
input,
45+
&VisitType {
46+
visit_trait: quote!(Visit),
47+
visitor_trait: quote!(Visitor),
48+
modifier: None,
49+
},
50+
)
2951
}
3052

3153
struct VisitType {
@@ -34,15 +56,16 @@ struct VisitType {
3456
modifier: Option<TokenStream>,
3557
}
3658

37-
fn derive_visit(
38-
input: proc_macro::TokenStream,
39-
visit_type: &VisitType,
40-
) -> proc_macro::TokenStream {
59+
fn derive_visit(input: proc_macro::TokenStream, visit_type: &VisitType) -> proc_macro::TokenStream {
4160
// Parse the input tokens into a syntax tree.
4261
let input = parse_macro_input!(input as DeriveInput);
4362
let name = input.ident;
4463

45-
let VisitType { visit_trait, visitor_trait, modifier } = visit_type;
64+
let VisitType {
65+
visit_trait,
66+
visitor_trait,
67+
modifier,
68+
} = visit_type;
4669

4770
let attributes = Attributes::parse(&input.attrs);
4871
// Add a bound `T: Visit` to every type parameter T.
@@ -87,7 +110,10 @@ impl Parse for WithIdent {
87110
let mut result = WithIdent { with: None };
88111
let ident = input.parse::<Ident>()?;
89112
if ident != "with" {
90-
return Err(syn::Error::new(ident.span(), "Expected identifier to be `with`"));
113+
return Err(syn::Error::new(
114+
ident.span(),
115+
"Expected identifier to be `with`",
116+
));
91117
}
92118
input.parse::<Token!(=)>()?;
93119
let s = input.parse::<LitStr>()?;
@@ -131,17 +157,26 @@ impl Attributes {
131157
}
132158

133159
// Add a bound `T: Visit` to every type parameter T.
134-
fn add_trait_bounds(mut generics: Generics, VisitType{visit_trait, ..}: &VisitType) -> Generics {
160+
fn add_trait_bounds(mut generics: Generics, VisitType { visit_trait, .. }: &VisitType) -> Generics {
135161
for param in &mut generics.params {
136162
if let GenericParam::Type(ref mut type_param) = *param {
137-
type_param.bounds.push(parse_quote!(sqlparser::ast::#visit_trait));
163+
type_param
164+
.bounds
165+
.push(parse_quote!(sqlparser::ast::#visit_trait));
138166
}
139167
}
140168
generics
141169
}
142170

143171
// Generate the body of the visit implementation for the given type
144-
fn visit_children(data: &Data, VisitType{visit_trait, modifier, ..}: &VisitType) -> TokenStream {
172+
fn visit_children(
173+
data: &Data,
174+
VisitType {
175+
visit_trait,
176+
modifier,
177+
..
178+
}: &VisitType,
179+
) -> TokenStream {
145180
match data {
146181
Data::Struct(data) => match &data.fields {
147182
Fields::Named(fields) => {

docs/benchmarking.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
# Benchmarking
221

322
Run `cargo bench` in the project `sqlparser_bench` execute the queries.

docs/custom_sql_parser.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
# Writing a Custom SQL Parser
221

322
I have explored many different ways of building this library to make it easy to extend it for custom SQL dialects. Most of my attempts ended in failure but I have now found a workable solution. It is not without downsides but this seems to be the most pragmatic solution.

docs/fuzzing.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
# Fuzzing
221

322
## Installing `honggfuzz`

docs/releasing.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
120
# Releasing
221

322
## Prerequisites

examples/cli.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
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
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
48
//
5-
// http://www.apache.org/licenses/LICENSE-2.0
9+
// http://www.apache.org/licenses/LICENSE-2.0
610
//
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.
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
1217

1318
#![warn(clippy::all)]
1419

0 commit comments

Comments
 (0)