Giter Site home page Giter Site logo

Additional types about p3 HOT 5 CLOSED

pidu avatar pidu commented on June 15, 2024
Additional types

from p3.

Comments (5)

svenvc avatar svenvc commented on June 15, 2024

Hmm, that is indeed not good.

The list of supported/implemented types can be found in P3Converter class>>#typeMap and since int2, int4 and int8 are already supported, it can't be too hard to add support for more integer types. All that is probably needed is to find the corresponding type oid and add entries. You can also find that type oid from the error you are now seeing.

Could you try that yourself ?

from p3.

pidu avatar pidu commented on June 15, 2024

I haven't really grokked how glorp and p3 work yet to understand what's going on. But a serial is just an integer (int4) with an autoincrementing sequence attached. Likewise a bigserial is just a int8 with a sequence. I had a look in pg_catalog.pg_type but found no references to serial or bigserial there. For bigint it's really just a synonym so one could use int8 instead.

But when describing a table column as begin of type platform serial using glorp and then creating the table I end up with a column without any autoincrementing sequence.

from p3.

svenvc avatar svenvc commented on June 15, 2024

You have to make a difference between P3 and Glorp.

P3 is a PostgreSQL client that allows you to execute textual SQL queries and process the results converting it into native types.

Glorp is an object-rdbm mapper on top of some DB client. The small class https://github.com/svenvc/P3/blob/master/P3-Glorp/P3DatabaseDriver.class.st is all there is to Glorp from the perspective of P3.

I did the following in psql command line against posgresql 9.6

create table test_1 (s smallint, i integer, b bigint, id serial);
insert into test_1 values (1, 2, 3);
insert into test_1 values (1, 2, 3);
select * from test_1;
s | i | b | id
---+---+---+----
1 | 2 | 3 | 1
1 | 2 | 3 | 2

In Pharo with P3 loaded, I did

(P3Client new url: 'psql://sven@localhost') in: [ :client |
[ client query: 'select * from test_1' ] ensure: [ client close ] ].

And got the correct results back. The data being

#(#(1 2 3 1) #(1 2 3 2))

So from the P3 standpoint all these types are supported and work correctly, AFAICT.

It seems you have some issues with Glorp. Those should be asked elsewhere, I would start with the Pharo mailing lists. Make sure to add some executable code.

Did you try running the Glorp unit tests on your setup ? When I did that a while ago, most of them were OK (like 80/90 %).

from p3.

pidu avatar pidu commented on June 15, 2024

I do understand the general difference between Glorp and P3. I just assumed that glorp was somehow using the P3 driver for the sql statement generation when creating tables. I could have made that clearer from the get go but I saw no reference to the big* or *serial types in P3Converter supportedTypes and just assumed that the failure to create a database sequence along with the integer column was that of the driver.

I ran across this in Glorp-Platform: PostgreSQLPlatform >> serial:

^ self typeNamed: #serial ifAbsentPut: [GlorpSerialType new typeString: 'integer' ]

I interpreted that as a fallback and assumed that was just checking the capability of the driver. I was apparently mistaken. Sorry about the noise.

Entirely unrelated to this. Are you planning on adding support for prepare statements? SQL-injection is a nasty thing.

from p3.

svenvc avatar svenvc commented on June 15, 2024

If you tell your Glorp session #logging: true and open a Transcript you can see all actual SQL statements being executed.

But Glorp is pretty complex.

I have used platform serial myself and it worked as expected (longer ago, for example https://medium.com/concerning-pharo/reddit-st-in-10-cool-pharo-classes-1b5327ca0740) - I would be quite surprised if it did no longer work or if it broke, but everything is possible.

With an OO-RDBMS mapper you do not have to be scared of SQL injection I think. With pure P3 or SQL in classic statements, you just have to handle your arguments carefully. I have no immediate plans to add prepared statements.

I am closing this issue now, you will probably get more/better help on the pharo mailing lists.

from p3.

Related Issues (20)

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.