Coder Social home page Coder Social logo

p3's People

Contributors

chisandrei avatar deem0n avatar draagrenkirneh avatar gcotelli avatar henriknergaard-ins avatar jurajkubelka avatar jvdsandt avatar lopezca avatar mahugnon avatar pavel-krivanek avatar svenvc avatar vince-refiti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p3's Issues

Tag reading when the database does not exist

When the database you try to connect does not exist, the method
P3MessageBuffer>>#readFrom: (called from P3Client>>#readMessageOnError:)
fails because the readStream next returns nil and the internal error handling does not expect such case.

Can't get P3 working after migration from Pharo 8 to 9

Hi,
I had to migrate from Pharo 8 to 9 and re-installed P3 with the following scripts (the same i had used to install P3 in Pharo 8)

Metacello new
baseline: 'P3';
repository: 'github://svenvc/P3';
load.

and

Metacello new
baseline: 'P3';
repository: 'github://svenvc/P3';
load: 'glorp'.

I also re-installed DBXTalk/Glorp/main
and "do-it" : PharoDatabaseAccessor DefaultDriver: P3DatabaseDriver.

Before that i installed Spec2.

Then i tried to run this script
(P3Client new url: 'psql://Richard:lulosa.2MA@localhost:5432/Glazux') in: [ :client |
[ client query: 'SELECT * FROM ingredients' ] ensure: [ client close ] ].

but got this error:
P3-Pbm

I probably forgot to do something but i don't remember what. Do i need to install a MetaRepoForPharo? But which version?
Thanks for help
Richard
(btw: the same script runs ok in Pharo 8)

Custom column type

I have the following custom column type: CREATE TYPE public.money_with_currency AS (currency_code char(3), amount numeric(20,8))

When running: select * from table with that column, I'm getting: P3Error Cannot convert type with OID 23409

Do you have any suggestions on how I could pass that type to P3?

Bug with Pharo 7

I just tested P3 with Pharo 7 and I got the following error message : Instance of ZnCharacterReadStream did not understand #binary.

The error is fired in ZTimezone >> fromFile: file

Using with glorp

Pharo 7 latest 32 bit, Ubuntu 16.04LTS, local postgres install

Following the glorp booklet, and adapting it to P3.

Metacello new
baseline: 'P3';
repository: 'github://svenvc/P3';
load: 'glorp'.

PharoDatabaseAccessor DefaultDriver: P3DatabaseDriver.

(section 4.5)
login := Login new
database: PostgreSQLPlatform new;
username: 'un';
password: 'pw';
connectString: 'localhost:5432_stephan';
encodingStrategy: #utf8;
yourself.
session := GlorpBookDescriptorSystem sessionForLogin: login.
session login

gives a
Instance of P3Client did not understand #queryEncoding

Additional types

Using glorp, I am trying to specify platform serial or platform bigint and realising that neither exists. The serial type in my experience seems pretty standard for primary key use. Would it be hard to add support for these? I understand that array support may be a bit more involved but is also rather more rare in use than serial types.

README.md typo

In the Unit tests section, you have the class name as P3ClientTests, whereas it should be P3ClientTest

custom P3 error classes

The error handling in P3 uses general error: calls on many places when something fails. It should signal custom errors with own classes so it can be more easily tested, converted and translated.

Can't handle array type

Trying to select a _varchar (array) column I get this Error (cannot convert typeOid 1015):

P3Converter(Object)>>error:
[ self
	error: 'P3 cannot convert typeOid ' , description typeOid asString ] in P3Converter>>convert:length:description:
IdentityDictionary(Dictionary)>>at:ifAbsent:
P3Converter>>convert:length:description:
P3RowFieldDescription>>convert:length:using:
P3Client>>processDataRowUsing:
[ :out | 
[ self readMessage tag = $C ]
	whileFalse: [ self assert: message tag = $D.
		out nextPut: (self processDataRowUsing: result descriptions) ] ] in P3Client>>runQueryResult
Array class(SequenceableCollection class)>>new:streamContents:
Array class(SequenceableCollection class)>>streamContents:
P3Client>>runQueryResult
P3Client>>query:
[ client
	query: 'select id,locale,created_at,confidential,rights from users limit 3' ] in [ :client | 
[ client
	query: 'select id,locale,created_at,confidential,rights from users limit 3' ]
	ensure: [ client close ] ] in UndefinedObject>>DoIt
BlockClosure>>ensure:
[ :client | 
[ client
	query: 'select id,locale,created_at,confidential,rights from users limit 3' ]
	ensure: [ client close ] ] in UndefinedObject>>DoIt
P3Client(Object)>>in:
UndefinedObject>>DoIt
OpalCompiler>>evaluate
RubSmalltalkEditor>>evaluate:andDo:
RubSmalltalkEditor>>highlightEvaluateAndDo:
[ textMorph textArea editor highlightEvaluateAndDo: ann action.
textMorph shoutStyler style: textMorph text ] in [ textMorph textArea
	handleEdit: [ textMorph textArea editor highlightEvaluateAndDo: ann action.
		textMorph shoutStyler style: textMorph text ] ] in GLMMorphicPharoScriptRenderer(GLMMorphicPharoCodeRenderer)>>actOnHighlightAndEvaluate:
RubEditingArea(RubAbstractTextArea)>>handleEdit:
[ textMorph textArea
	handleEdit: [ textMorph textArea editor highlightEvaluateAndDo: ann action.
		textMorph shoutStyler style: textMorph text ] ] in GLMMorphicPharoScriptRenderer(GLMMorphicPharoCodeRenderer)>>actOnHighlightAndEvaluate:
WorldState>>runStepMethodsIn:
WorldMorph>>runStepMethods
WorldState>>doOneCycleNowFor:
WorldState>>doOneCycleFor:
WorldMorph>>doOneCycle
WorldMorph class>>doOneCycle
[ [ WorldMorph doOneCycle.
Processor yield.
false ] whileFalse: [  ] ] in MorphicUIManager>>spawnNewProcess
[ self value.
Processor terminateActive ] in BlockClosure>>newProcess

Problems with setting the parameters of P3PreparedStatement

Currently the P3PreparedStatement >> #bindString: method just sends asString to each parameter. This works for some objects like Strings, Integers and Booleans, but not for ByteArrays, ScaledDecimals and probably some others.

I think we need a more intelligent conversion strategy. I see two options:

  1. Dispatch to a convertParameter method in P3Converter to make to conversion dependent on the parameter type.
  2. Make use of an extension method to do the conversion with a default implementation in Object. The extension method can be something like:
writeAsP3TextParameterOn: aStream type: aParameterDescription 
	"default implementation"
	self printOn: aStream

And for ByteArray:

writeAsP3TextParameterOn: aStream type: aParameterDescription 
	aStream nextPutAll: '\x'; nextPutAll: self hex

I think the seconds option is the most flexible but this option does require adding some class extensions.

Question about ip addr support

Hi, I can not find standard class in Pharo for IPv4 and IPv6 addresses, so probably we can just use text representation for PostgreSQL type inet and friends ?

If that is accepted, I could make a PR.

Reset in P3Client>>connect drop password

Just a few minutes in to trying P3. After doing...
Metacello new
baseline: 'P3';
repository: 'github://svenvc/P3';
load.

Doing...
(P3Client new url: 'psql://postgres:xxxxx@localhost:5432/nyc_data') in: [ :client |
[ client isWorking ] ensure: [ client close ] ].
produces... "P3Error PostgreSQL Password required"

Tracing through, in P3CLient>>connect I find...
self ==> a P3Client(psql://postgres:xxxxxx@localhost:5432/nyc_data)
before sending #reset, and after...
self ==> a P3Client(psql://localhost:5432/)

Now it works if I comment out "self reset".

Prepared statements error when query is long and differs slightly at the end

Hello, psql prepared statements are identified by "name" (https://www.postgresql.org/docs/current/view-pg-prepared-statements.html), but in P3 client, the whole query is used as name - but, psql prepared statement name is limited :(

Imagine this two queries:
select id, name, enabled from table1 where name = ''123'' and id = 1
This query is prepared - OK.
Second query:
select id, name, enabled from table1 where name = ''123'' and id = 2
Bang! PostgreSQL error message: P3Error PostgreSQL prepared statement "select id, name, enabled from table1 where name = '123' and id = 2" already exists

How to solve this? Add second peramater to the P3Client prepare: or maybe better, use some sort of hashes as prepared statement names internally?

Use of pgcrypto, can't call crypt?

I'm attempting to use pgcrypto, specifically this: select crypt('password', gen_salt('bf')) and I'm unable to make it work. I've tried with prepared statements and formatted statements alike trying to replace 'bf' with a parameter $2 and trying to just leave it inline with the single quotes escaped like so: gen_salt(''bf''). I thought this would be straightforward but I'm a bit stumped.

connect to PGSQL 10.6. but error with Timezone class

server : postgresql 10.6 with gentoo linux
pharo : pharo 7.0

test code :

(P3Client new url: 'psql://frontend:[email protected]:5432/pegarelease') in: [ :client |
   [ client query: 'SELECT * FROM system_countries' ] ensure: [ client close ] ].

but encounterd this error...

readTimezoneWithId : [ ^ self error: 'Unknown Timezone ID: ' , id asString ]

id Value is "ROK". how to solve this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.