Skip to content

Commit

Permalink
Unexport types
Browse files Browse the repository at this point in the history
  • Loading branch information
iamed2 committed Feb 21, 2018
1 parent 159fc66 commit 22558cf
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 49 deletions.
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### Selection

```julia
conn = Connection("dbname=postgres")
conn = LibPQ.Connection("dbname=postgres")
result = execute(conn, "SELECT typname FROM pg_type WHERE oid = 16")
data = Data.stream!(result, NamedTuple)
clear!(result)
Expand All @@ -29,7 +29,7 @@ close(conn)
### Insertion

```julia
conn = Connection("dbname=postgres user=$DATABASE_USER")
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER")

result = execute(conn, """
CREATE TEMPORARY TABLE libpqjl_test (
Expand All @@ -41,7 +41,7 @@ clear!(result)

Data.stream!(
data,
Statement,
LibPQ.Statement,
conn,
"INSERT INTO libpqjl_test (no_nulls, yes_nulls) VALUES (\$1, \$2);",
)
Expand Down
34 changes: 17 additions & 17 deletions docs/src/pages/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ end
LibPQ.Connection
execute
prepare
status(::Connection)
Base.close(::Connection)
Base.isopen(::Connection)
reset!(::Connection)
Base.show(::IO, ::Connection)
status(::LibPQ.Connection)
Base.close(::LibPQ.Connection)
Base.isopen(::LibPQ.Connection)
reset!(::LibPQ.Connection)
Base.show(::IO, ::LibPQ.Connection)
```

### Results

```@docs
LibPQ.Result
status(::Result)
clear!(::Result)
num_rows(::Result)
num_columns(::Result)
Base.show(::IO, ::Result)
status(::LibPQ.Result)
clear!(::LibPQ.Result)
num_rows(::LibPQ.Result)
num_columns(::LibPQ.Result)
Base.show(::IO, ::LibPQ.Result)
```

### Statements

```@docs
LibPQ.Statement
num_columns(::Statement)
num_params(::Statement)
Base.show(::IO, ::Statement)
num_columns(::LibPQ.Statement)
num_params(::LibPQ.Statement)
Base.show(::IO, ::LibPQ.Statement)
```

### DataStreams Integration

```@docs
LibPQ.Statement(::LibPQ.DataStreams.Data.Schema, ::Type{LibPQ.DataStreams.Data.Row}, ::Bool, ::Connection, ::AbstractString)
LibPQ.Statement(::LibPQ.DataStreams.Data.Schema, ::Type{LibPQ.DataStreams.Data.Row}, ::Bool, ::LibPQ.Connection, ::AbstractString)
LibPQ.fetch!
```

Expand All @@ -60,7 +60,7 @@ LibPQ.set_encoding!
LibPQ.reset_encoding!
LibPQ.transaction_status
LibPQ.unique_id
LibPQ.error_message(::Connection)
LibPQ.error_message(::LibPQ.Connection)
```

### Connection Info
Expand All @@ -81,8 +81,8 @@ LibPQ.column_names
LibPQ.column_number
LibPQ.column_oids
LibPQ.column_types
LibPQ.num_params(::Result)
LibPQ.error_message(::Result)
LibPQ.num_params(::LibPQ.Result)
LibPQ.error_message(::LibPQ.Result)
```

### Type Conversions
Expand Down
1 change: 0 additions & 1 deletion src/LibPQ.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module LibPQ

export Connection, Result, Statement
export status, reset!, execute, clear, fetch!, prepare,
num_columns, num_rows, num_params

Expand Down
56 changes: 28 additions & 28 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ end
const DATABASE_USER = get(ENV, "LIBPQJL_DATABASE_USER", "postgres")

@testset "Example SELECT" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=false)
@test conn isa Connection
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=false)
@test conn isa LibPQ.Connection
@test isopen(conn)
@test status(conn) == LibPQ.libpq_c.CONNECTION_OK
@test conn.closed == false
Expand All @@ -73,7 +73,7 @@ end
"SELECT typname FROM pg_type WHERE oid = 16";
throw_error=false,
)
@test result isa Result
@test result isa LibPQ.Result
@test status(result) == LibPQ.libpq_c.PGRES_TUPLES_OK
@test result.cleared == false
@test LibPQ.num_columns(result) == 1
Expand All @@ -95,7 +95,7 @@ end
[16];
throw_error=false,
)
@test result isa Result
@test result isa LibPQ.Result
@test status(result) == LibPQ.libpq_c.PGRES_TUPLES_OK
@test result.cleared == false
@test LibPQ.num_columns(result) == 1
Expand Down Expand Up @@ -127,7 +127,7 @@ end
end

@testset "Example INSERT" begin
conn = Connection("dbname=postgres user=$DATABASE_USER")
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER")

result = execute(conn, """
CREATE TEMPORARY TABLE libpqjl_test (
Expand Down Expand Up @@ -161,7 +161,7 @@ end

stmt = Data.stream!(
data,
Statement,
LibPQ.Statement,
conn,
"INSERT INTO libpqjl_test (no_nulls, yes_nulls) VALUES (\$1, \$2);",
)
Expand All @@ -188,32 +188,32 @@ end
close(conn)
end

@testset "Connection" begin
@testset "LibPQ.Connection" begin
@testset "do" begin
local saved_conn

was_open = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true) do jl_conn
was_open = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true) do jl_conn
saved_conn = jl_conn
return isopen(jl_conn)
end

@test was_open
@test !isopen(saved_conn)

@test_throws ErrorException Connection("dbname=123fake"; throw_error=true) do jl_conn
@test_throws ErrorException LibPQ.Connection("dbname=123fake"; throw_error=true) do jl_conn
@test false
end
end

@testset "Version Numbers" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

# update this test before PostgreSQL 20.0 ;)
@test LibPQ.pqv"7" <= LibPQ.server_version(conn) <= LibPQ.pqv"20"
end

@testset "Encoding" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

@test LibPQ.encoding(conn) == "UTF8"

Expand All @@ -240,8 +240,8 @@ end

@testset "Bad Connection" begin
@testset "throw_error=false" begin
conn = Connection("dbname=123fake"; throw_error=false)
@test conn isa Connection
conn = LibPQ.Connection("dbname=123fake"; throw_error=false)
@test conn isa LibPQ.Connection
@test status(conn) == LibPQ.libpq_c.CONNECTION_BAD
@test conn.closed == false

Expand All @@ -256,10 +256,10 @@ end
end

@testset "throw_error=true" begin
@test_throws ErrorException Connection("dbname=123fake"; throw_error=true)
@test_throws ErrorException LibPQ.Connection("dbname=123fake"; throw_error=true)

conn = Connection("dbname=123fake"; throw_error=false)
@test conn isa Connection
conn = LibPQ.Connection("dbname=123fake"; throw_error=false)
@test conn isa LibPQ.Connection
@test status(conn) == LibPQ.libpq_c.CONNECTION_BAD
@test conn.closed == false

Expand All @@ -273,7 +273,7 @@ end

@testset "Results" begin
@testset "Nulls" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

result = execute(conn, "SELECT NULL"; throw_error=true)
@test status(result) == LibPQ.libpq_c.PGRES_TUPLES_OK
Expand Down Expand Up @@ -316,7 +316,7 @@ end
""";
throw_error=true,
)
@test result isa Result
@test result isa LibPQ.Result
@test status(result) == LibPQ.libpq_c.PGRES_TUPLES_OK
@test LibPQ.num_rows(result) == 2
@test LibPQ.num_columns(result) == 2
Expand All @@ -332,7 +332,7 @@ end
end

@testset "Not Nulls" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

result = execute(conn, "SELECT NULL"; not_null=[false], throw_error=true)
@test status(result) == LibPQ.libpq_c.PGRES_TUPLES_OK
Expand Down Expand Up @@ -412,7 +412,7 @@ end

@testset "Type Conversions" begin
@testset "Automatic" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

result = execute(conn, """
SELECT oid, typname, typlen, typbyval, typcategory
Expand All @@ -422,7 +422,7 @@ end
""";
throw_error=true,
)
@test result isa Result
@test result isa LibPQ.Result
@test status(result) == LibPQ.libpq_c.PGRES_TUPLES_OK
@test LibPQ.num_rows(result) == 3
@test LibPQ.num_columns(result) == 5
Expand All @@ -443,7 +443,7 @@ end

@testset "Parsing" begin
@testset "Default Types" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

test_data = [
("3", Cint(3)),
Expand Down Expand Up @@ -534,7 +534,7 @@ end
end

@testset "Specified Types" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

test_data = [
("3", UInt, UInt(3)),
Expand Down Expand Up @@ -578,7 +578,7 @@ end

@testset "Query Errors" begin
@testset "Syntax Errors" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

result = execute(conn, "SELORCT NUUL;"; throw_error=false)
@test status(result) == LibPQ.libpq_c.PGRES_FATAL_ERROR
Expand All @@ -596,7 +596,7 @@ end
end

@testset "Wrong No. Parameters" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

result = execute(conn, "SELORCT \$1;", String[]; throw_error=false)
@test status(result) == LibPQ.libpq_c.PGRES_FATAL_ERROR
Expand All @@ -620,7 +620,7 @@ end
end

@testset "Interface Errors" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

result = execute(
conn,
Expand All @@ -637,7 +637,7 @@ end

@testset "Statements" begin
@testset "No Params, Output" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

stmt = prepare(conn, "SELECT oid, typname FROM pg_type")

Expand All @@ -658,7 +658,7 @@ end
end

@testset "Params, Output" begin
conn = Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)
conn = LibPQ.Connection("dbname=postgres user=$DATABASE_USER"; throw_error=true)

stmt = prepare(conn, "SELECT oid, typname FROM pg_type WHERE oid = \$1")

Expand Down

0 comments on commit 22558cf

Please sign in to comment.