Giter Site home page Giter Site logo

fluent-provider's Introduction

fluent-provider's People

Contributors

alextdavis avatar brettrtoomey avatar gwynne avatar jobinsjohn avatar johnbona avatar lightwave avatar loganwright avatar rb-de0 avatar tanner0101 avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar

fluent-provider's Issues

Bug: Raw Query Group By

Using a raw Query with Fluent I get wrong numbers from my query

guard let majorSet = try? Job.database?.raw("select major, avg(pay) as average from jobs group by major order by average desc").converted(to: JSON.self).makeResponse() else { throw SQL.serialization }

I get the following Response which is wrong:

[
{
"major": "Product Design",
"average": "0.000000116400"
},
{
"major": "Software Engineering",
"average": "0.000000000009"
},
{
"major": "Computer Science",
"average": "0.000000082500"
},
{
"major": "Computer Engineering",
"average": "0.000000065000"
},
{
"major": "Chemical Engineering",
"average": "0.000000058224"
},
{
"major": "Accounting",
"average": "0.000000055000"
},
{
"major": "Information Technology",
"average": "0.000000054000"
},
{
"major": "Marketing",
"average": "0.000000036000"
}
]

As those values should be whole numbers

SQLite configuration ignores workDir

Unlike other parts of Vapor, the SQLite configuration does not prepend the calculated working directory to the database path.

When the project is executed in Xcode with default scheme settings, this results in the database file being created in DerivedData instead of the project folder.

(Command line and Linux builds are not affected.)

Logging preparation queries

If we log using the following

drop.database?.log = { query in
    print(query)
}

The the queries for the preparations are not logged as they are called during the init of the Droplet.

Updateable protocol issue with null values

Vapor Toolbox: 2.0.3
Vapor Framework: 2.1.2

Given the following code, Updateable protocol can not convert null to nil for the string as expected:

final class Reminder: Model {

    var calendarItemIdentifier: String?

 struct Properties {
        static let idKey                     = "id"
        static let calendarItemIdentifierKey = "calendar_item_identifier"
    }

 init(row: Row) throws {
        calendarItemIdentifier = try? row.get(Properties.calendarItemIdentifierKey)
}

 func makeRow() throws -> Row {
        var row = Row()
        try row.set(Properties.calendarItemIdentifierKey, calendarItemIdentifier)
}

extension Reminder: Preparation {
    static func prepare(_ database: Database) throws {
        try database.create(self) { reminder in
            reminder.id()
            reminder.string(Properties.calendarItemIdentifierKey, optional: true)
        }
    }
    
    static func revert(_ database: Database) throws {
        try database.delete(self)
    }
}

extension Reminder: Updateable {
    public static var updateableKeys: [UpdateableKey<Reminder>] {
        return [
            UpdateableKey(Properties.calendarItemIdentifierKey, String.self) { object, calendarItemIdentifier in
                object.calendarItemIdentifier = calendarItemIdentifier
            }
        ]
    }
}

Attempting to patch through

    func update(req: Request, reminder: Reminder) throws -> ResponseRepresentable {
        try reminder.update(for: req)
        
        try reminder.save()
        return try reminder
    }

With

{
  "calendar_item_identifier": null
}

Fluent is throwing an error

capture d ecran 2017-08-11 a 09 56 26
capture d ecran 2017-08-11 a 09 56 43

Linux: libCSQLite.so "error: undefined reference..."

Hi,
My environment:

  • OS: Ubuntu
  • Version: 16.10

My Package.swift:

import PackageDescription

let package = Package(
    name: "ItWorks-Sqlite",
    targets: [
        Target(name: "App"),
        Target(name: "Run", dependencies: ["App"]),
    ],
    dependencies: [
        .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2),
        .Package(url: "https://github.com/vapor/fluent-provider.git", majorVersion: 1),
    ],
    exclude: [
        "Config",
        "Database",
        "Localization",
        "Public",
        "Resources",
    ]
)

My output:

# vapor build
Building Project [Failed]

Command:
build --enable-prefetching

Error (1):
<unknown>:0: error: build had 1 command failures
swift-build: error: exit(1): /usr/bin/swift-build-tool -f /vapor/ItWorks-Sqlite/.build/debug.yaml


Output:
Linking ./.build/debug/Run
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'pthread_mutexattr_destroy'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'pthread_mutexattr_init'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'pthread_create'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'dlsym'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'dlerror'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'pthread_mutex_trylock'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'dlclose'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'pthread_mutexattr_settype'
/vapor/ItWorks-Sqlite/.build/debug/libCSQLite.so: error: undefined reference to 'dlopen'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)


Toolchain:
/usr/bin/swift

Help:
Join our Slack where hundreds of contributors
are waiting to help: http://vapor.team

Error: Build failed.

Can't install provider: swift-package: error: unsatisfiable

Package.swift:

let package = Package(
    name: "test-vapor",
    dependencies: [
        .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2),
        .Package(url: "https://github.com/vapor/fluent-provider.git", majorVersion: 1)
    ],
    exclude: [
        "Config",
        "Database",
        "Localization",
        "Public",
        "Resources",
    ]
)

Running vapor build --clean returns the error:

Cleaning [Done]
No .build folder, fetch may take a while...
Fetching Dependencies [Failed]
Error: swift-package: error: unsatisfiable

Invalid syntax in warning

The warning If you want to use models with Fluent, make sure to add the model to the Droplet's preparations array, e.g., drop.preparations += ModelType.self is useful for detecting misconfigured projects, except for the recommended fix is invalid swift. It should be updated to either drop.preparations.append(ModelType.self) or use an array of preparations.

Here's the line of code: https://github.com/vapor/fluent-provider/blob/3c2cb5cf3c0b9cb387f65f8df410e927815985f5/Sources/FluentProvider/Provider.swift#L161

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.