Skip to content

Commit

Permalink
fix(driver): decode percent encoded password for flightsql (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored May 18, 2023
1 parent 7869956 commit ea34350
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ shlex = "1.1.0"
sqlformat = "0.2.1"
strum = "0.24"
strum_macros = "0.24"
tokio = { version = "1.26", features = [
tokio = { version = "1.28.1", features = [
"macros",
"rt",
"rt-multi-thread",
Expand Down
1 change: 1 addition & 0 deletions driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ chrono = { version = "0.4.24", default-features = false, features = ["clock"] }
databend-client = { version = "0.1.16", path = "../core" }
dyn-clone = "1.0.11"
http = "0.2.9"
percent-encoding = "2.2.0"
serde = { version = "1.0.160", default-features = false, features = ["derive"] }
serde_json = { version = "1.0.96", default-features = false, features = ["std"] }
tokio = { version = "1.27.0", features = ["macros"] }
Expand Down
5 changes: 4 additions & 1 deletion driver/src/flight_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use arrow_flight::utils::flight_data_to_arrow_batch;
use arrow_flight::{sql::client::FlightSqlServiceClient, FlightData};
use arrow_schema::SchemaRef as ArrowSchemaRef;
use async_trait::async_trait;
use percent_encoding::percent_decode_str;
use tokio::sync::Mutex;
use tokio_stream::{Stream, StreamExt};
use tonic::transport::{Channel, ClientTlsConfig, Endpoint};
Expand Down Expand Up @@ -247,7 +248,9 @@ impl Args {
None => format!("{}://{}:{}", scheme, host, port),
};
args.user = u.username().to_string();
args.password = u.password().unwrap_or_default().to_string();
args.password = percent_decode_str(u.password().unwrap_or_default())
.decode_utf8_lossy()
.to_string();
Ok(args)
}
}
Expand Down
10 changes: 5 additions & 5 deletions driver/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use arrow::datatypes::i256;
use arrow::datatypes::{i256, ArrowNativeTypeOp};
use chrono::{Datelike, NaiveDate, NaiveDateTime};

use crate::{
Expand All @@ -28,10 +28,10 @@ const NULL_VALUE: &str = "NULL";
#[cfg(feature = "flight-sql")]
use {
arrow_array::{
Array as ArrowArray, ArrowNativeTypeOp, BinaryArray, BooleanArray, Date32Array,
Decimal128Array, Decimal256Array, Float32Array, Float64Array, Int16Array, Int32Array,
Int64Array, Int8Array, LargeBinaryArray, LargeStringArray, StringArray,
TimestampMicrosecondArray, UInt16Array, UInt32Array, UInt64Array, UInt8Array,
Array as ArrowArray, BinaryArray, BooleanArray, Date32Array, Decimal128Array,
Decimal256Array, Float32Array, Float64Array, Int16Array, Int32Array, Int64Array, Int8Array,
LargeBinaryArray, LargeStringArray, StringArray, TimestampMicrosecondArray, UInt16Array,
UInt32Array, UInt64Array, UInt8Array,
},
arrow_schema::{DataType as ArrowDataType, Field as ArrowField, TimeUnit},
std::sync::Arc,
Expand Down

0 comments on commit ea34350

Please sign in to comment.